nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
68.15k stars 7.66k forks source link

Website reports error - unhandledRejection: TypeError: Cannot read properties of undefined (reading 'bind') #11810

Closed raychunghk closed 1 year ago

raychunghk commented 1 year ago

Is there an existing issue for this?

Current behavior

I setup a project with the main.js as below,

` import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; import { join } from 'path'; import { RenderService } from 'nest-next'; import * as passport from 'passport'; import fastifySession from 'fastify-session'; import secureSession from '@fastify/secure-session'; async function bootstrap() {

const app = await NestFactory.create( AppModule, new FastifyAdapter(), ); await app.register(secureSession, { secret: 'averylogphrasebiggerthanthirtytwochars', salt: 'mq9hDxBVDbspDR6n', }); app.setGlobalPrefix(/absproxy/5000);

await app.listen(5000);

} bootstrap();

`

it will report unhandledRejection: TypeError: Cannot read properties of undefined (reading 'bind')

If I change to below, taking out the adapter param, it works: ` const app = await NestFactory.create( AppModule );

`

Minimum reproduction code

https://github.com/raychunghk/NxTime/blob/main/src/server/main.ts

Steps to reproduce

No response

Expected behavior

It should work by just copy/paste from the official documentation. `import secureSession from '@fastify/secure-session';

// somewhere in your initialization file const app = await NestFactory.create( AppModule, new FastifyAdapter(), ); await app.register(secureSession, { secret: 'averylogphrasebiggerthanthirtytwochars', salt: 'mq9hDxBVDbspDR6n', });`

Package

Other package

No response

NestJS version

10.0.0

Packages versions

  "@nestjs/apollo": "^11.0.6",
    "@nestjs/common": "^9.4.3",
    "@nestjs/core": "^10.0.0",
    "@nestjs/graphql": "^11.0.6",
    "@nestjs/jwt": "^10.0.3",
    "@nestjs/passport": "^9.0.3",
    "@nestjs/platform-express": "^9.4.3",
    "@nestjs/platform-fastify": "9.4.3",
    "@nestjs/serve-static": "^3.0.1",
    "@next/bundle-analyzer": "^13.4.4",

Node.js version

No response

In which operating systems have you tested?

Other

No response

kamilmysliwiec commented 1 year ago

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.