#start:dev script dont stop reloading

36 messages · Page 1 of 1 (latest)

outer patio
#

Please run nest info and post the results here.

modern mango
#

[System Information]
OS Version : macOS 23.4.0
NodeJS Version : v20.10.0
YARN Version : 1.22.19

[Nest CLI]
Nest CLI Version : 10.3.2

[Nest Platform Information]
platform-socket.io version : 10.3.3
platform-express version : 10.3.3
cache-manager version : 2.2.1
event-emitter version : 2.0.4
mapped-types version : 2.0.5
websockets version : 10.3.3
schematics version : 10.1.1
mongoose version : 10.0.4
passport version : 10.0.3
schedule version : 4.0.1
terminus version : 10.2.3
swagger version : 7.3.0
testing version : 10.3.3
common version : 10.3.3
config version : 3.2.0
axios version : 3.0.2
bull version : 10.1.0
core version : 10.3.3
jwt version : 10.2.0
cli version : 10.3.2
version : 2.0.2

outer patio
#

Ok. When it hangs, can you see what module it is working on?

modern mango
#

Give me a second, i will record the screen

outer patio
#

How are you calling the start script?

modern mango
#
  "scripts": {
    "build": "nest build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "start:dev": "NODE_ENV=local nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:build": "node dist/main",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest",
    "test:watch": "jest --watch",
    "test:cov": "jest --coverage",
    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
    "test:e2e": "jest --config ./test/jest-e2e.json"
  },

yarn start:dev

outer patio
#

Try
NEST_DEBUG=true yarn start:dev and see what happens.

#

What is the intention of setting NODE_ENV to "local"?

modern mango
#

Ill send you a wetransfer with the video

#

i have tried removing the NODE_ENV

#

and it keeps reloading

outer patio
#

Do you also have any code that is writing or updating files?

#

In other words, can you run yarn build with no issue?

modern mango
#

yes

outer patio
#

Yes to which question?

modern mango
#

i can build with no issue

#

the problem is with the --watch tag

outer patio
#

So, do you have code that is updating files during bootup?

modern mango
#

nope

#

this is why i use the NODE_ENV=local

@Module({
  imports: [
    LoggerModule.forRoot({
      pinoHttp:
        process.env.NODE_ENV === 'local'
          ? {
              timestamp: true,
              level: process.env.ENV !== 'production' ? 'trace' : 'debug',
              transport: {
                target: 'pino-pretty',
                options: {
                  messageKey: 'message',
                  colorize: true,
                  singleLine: true,
                  ignore: 'pid,hostname'
                }
              },
              autoLogging: false,
              messageKey: 'message',
              customProps: (req, _res) => {
                return {
                  correlation: (req as CorrelationRequest)[
                    CORRELATION_ID_HEADER
                  ]
                }
              },
              serializers: {
                req: (req: Request) => undefined,
                res: (res: Response) => undefined
              }
            }
          : {}
    })
  ]
})
export class AuditModule {
  configure(consumer: MiddlewareConsumer) {
    consumer.apply(CorrelationIdMiddleware).forRoutes('*')
  }
}


#

this is my nest-cli.json

{
 "$schema": "https://json.schemastore.org/nest-cli",
 "collection": "@nestjs/schematics",
 "sourceRoot": "src",
 "compilerOptions": {
   "assets": [
     {
       "include": "/templates/**/*.hbs",
       "outDir": "/dist/templates",
       "watchAssets": true
     }
   ],
   "deleteOutDir": true,
   "plugins": [
     {
       "name": "@nestjs/swagger",
       "options": {
         "classValidatorShim": false,
         "typeFileNameSuffix": [
           ".input.ts",
           ".dto.ts",
           ".args.ts",
           ".entity.ts",
           ".response.ts",
           ".model.ts"
         ],
         "introspectComments": true
       }
     }
   ]
 }
}

outer patio
#

Hmm.. the Swagger plugin does write to the files AFAIK:

#

Was your app working at all at any point?

modern mango
#

yess

#

i've implemented this script to make the script work

#

and then i just call setupSwagger at main.ts

outer patio
#

i've implemented this script to make the script work
To make what script work?

modern mango
#

sorry xd, to make swagger enums work

#

but it doesn't write any file

outer patio
#

Yeah, so this is too convoluted to figure out like this. And, I don't use Swagger or the CLI plugin.

modern mango
#

its weird because now it works but maybe tomorrow starts reloading in a loop

outer patio
#

So, I'm not going to be much help. And I'm not even sure the Swagger plugin is the issue.

modern mango
#

I dont think soo because i have a colleague that uses the same script on other project and it's working fine

outer patio
#

🤷🏻‍♂️