Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hot reload does not work properly #14838

Open
2 of 15 tasks
coderlzw-cn opened this issue Mar 24, 2025 · 6 comments
Open
2 of 15 tasks

Hot reload does not work properly #14838

coderlzw-cn opened this issue Mar 24, 2025 · 6 comments

Comments

@coderlzw-cn
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Kapture.2025-03-24.at.10.15.28.mp4

Minimum reproduction code

https://stackblitz.com/edit/nestjs-typescript-starter-7hmvnlhs?file=src%2Fmain.ts

Steps to reproduce

https://docs.nestjs.com/recipes/hot-reload

Expected behavior

How should I implement hot reload and ensure that the service is accessible

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

No response

NestJS version

11.0.1

Packages versions

  "dependencies": {
    "@nestjs/common": "^11.0.1",
    "@nestjs/core": "^11.0.1",
    "@nestjs/platform-express": "^11.0.1",
    "reflect-metadata": "^0.2.2",
    "rxjs": "^7.8.1"
  },
  "devDependencies": {
    "@eslint/eslintrc": "^3.2.0",
    "@eslint/js": "^9.18.0",
    "@nestjs/cli": "^11.0.0",
    "@nestjs/schematics": "^11.0.0",
    "@nestjs/testing": "^11.0.1",
    "@swc/cli": "^0.6.0",
    "@swc/core": "^1.10.7",
    "@types/express": "^5.0.0",
    "@types/jest": "^29.5.14",
    "@types/node": "^22.10.7",
    "@types/supertest": "^6.0.2",
    "eslint": "^9.18.0",
    "eslint-config-prettier": "^10.0.1",
    "eslint-plugin-prettier": "^5.2.2",
    "globals": "^16.0.0",
    "jest": "^29.7.0",
    "prettier": "^3.4.2",
    "run-script-webpack-plugin": "^0.2.2",
    "source-map-support": "^0.5.21",
    "supertest": "^7.0.0",
    "ts-jest": "^29.2.5",
    "ts-loader": "^9.5.2",
    "ts-node": "^10.9.2",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^5.7.3",
    "typescript-eslint": "^8.20.0",
    "webpack": "^5.98.0",
    "webpack-node-externals": "^3.0.0"
  },

Node.js version

v20.19.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@coderlzw-cn coderlzw-cn added the needs triage This issue has not been looked into label Mar 24, 2025
@lioncedric
Copy link

It was working before and now I have exactly the same issue :(

@kacime
Copy link

kacime commented Mar 26, 2025

Same problem here as well

@micalevisk
Copy link
Member

I didn't manage to spot the broken version. Both nestjs cli v10 and v11 behaves the same (the HRM seems not to be working). @lioncedric @kacime @coderlzw-cn can't you revert your code (including the lock file of package.json) to the point where the hot reload was working?

@sergiupris
Copy link

sergiupris commented Mar 27, 2025

Downgrading "run-script-webpack-plugin" to "0.2.1" fixes the issue.

Process is killed, module.hot.dispose not even called within main.ts. As right now signal (defaults to false) was removed in if check: atassis/run-script-webpack-plugin#30 , atassis/run-script-webpack-plugin#32


Another solution using "run-script-webpack-plugin": "0.2.2" (latest) is:

autoRestart: true, // previous: false - Not quite the same but

Another solution using "run-script-webpack-plugin": "0.2.2" (latest) is:

// Moving app.close from module.hot.dispose to, also leaving dispose with an async callback
process.on('SIGTERM', async () => {
    if (app) {
      await app.close();
    }
});

@kamilmysliwiec
Copy link
Member

Is this something we should report in the run-script-webpack-plugin repository?

@kacime
Copy link

kacime commented Mar 27, 2025

Thank you @sergiupris !

@micalevisk micalevisk removed the needs triage This issue has not been looked into label Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants