Closed truongtrongtin closed 11 months ago
Fastify adapter: POST request is hanged, GET request works fine
let nestApp: NestFastifyApplication; async function bootstrap() { const app = await NestFactory.create<NestFastifyApplication>( AppModule, new FastifyAdapter(), ); return app.init(); } export async function api(req: Request, res: Response) { nestApp = nestApp ?? (await bootstrap()); const instance = nestApp.getHttpAdapter().getInstance(); await instance.ready(); instance.server.emit('request', req, res); }
Express adapter works fine
let nestApp: NestExpressApplication; async function bootstrap() { const app = await NestFactory.create<NestExpressApplication>( AppModule, new ExpressAdapter(), ); return app.init(); } export async function api(req: Request, res: Response) { nestApp = nestApp ?? (await bootstrap()); const instance = nestApp.getHttpAdapter().getInstance(); instance(req, res); }
https://github.com/truongtrongtin/nestjs-function/blob/main/src/main.ts
pnpm install pnpm run start:dev curl -X POST http://localhost:8080 -d "name=john"
Should works
No response
"dependencies": { "@google-cloud/functions-framework": "^3.3.0", "@nestjs/common": "^10.2.10", "@nestjs/core": "^10.2.10", "@nestjs/platform-express": "^10.2.10", "@nestjs/platform-fastify": "^10.2.10", "class-validator": "^0.14.0", "reflect-metadata": "^0.1.13", "rxjs": "^7.8.1" }, "devDependencies": { "@nestjs/cli": "^10.2.1", "@nestjs/schematics": "^10.0.3", "@nestjs/testing": "^10.2.10", "@types/express": "^4.17.21", "@types/jest": "^29.5.10", "@types/node": "^20.10.1", "@types/supertest": "^2.0.16", "@typescript-eslint/eslint-plugin": "^6.13.1", "@typescript-eslint/parser": "^6.13.1", "env-cmd": "^10.1.0", "eslint": "^8.54.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-prettier": "^5.0.1", "jest": "^29.7.0", "prettier": "^3.1.0", "source-map-support": "^0.5.21", "supertest": "^6.3.3", "ts-jest": "^29.1.1", "ts-loader": "^9.5.1", "ts-node": "^10.9.1", "tsc-watch": "^6.0.4", "tsconfig-paths": "^4.2.0", "typescript": "^5.3.2" },
20.10.0
Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.
Is there an existing issue for this?
Current behavior
Fastify adapter: POST request is hanged, GET request works fine
Express adapter works fine
Minimum reproduction code
https://github.com/truongtrongtin/nestjs-function/blob/main/src/main.ts
Steps to reproduce
Expected behavior
Should works
Package
Other package
No response
NestJS version
No response
Packages versions
Node.js version
20.10.0
In which operating systems have you tested?
Other
No response