Ts-node-dev: why Nest.js Project slower on ts-node-dev with >= Node.js v10.16.0, frozen after [INFO] 10:46:03 Restarting: /xxx/xxx.ts has been modified

Created on 23 Aug 2019  ยท  7Comments  ยท  Source: wclr/ts-node-dev

My ENV:
macOS v10.14.6 + Node v12.8.1

Try:

  1. change to "ts-node-dev": "1.0.0-pre.35 / 37 / 39 / 40 / 41" in Node v12.8.1, The problem is still.
  2. change to "ts-node-dev": "1.0.0-pre.41" and Node v10.13.0 LTS, It's works!

so, How can I work under "ts-node-dev": "1.0.0-pre.41" and Node v12.8.1 now?
it's a bug?

Most helpful comment

@jonjaques I refer to this https://github.com/whitecolor/ts-node-dev/issues/51#issuecomment-490764844 and it works fine on node.js v12.13.0.

finally solved the problem. ๐Ÿ˜„

// package.json

"dev-tsnodedev": "NODE_ENV=development ts-node-dev --respawn --transpileOnly --ignore-watch node_modules -r tsconfig-paths/register ./src/main.ts",

All 7 comments

My test list (with "ts-node-dev": "1.0.0-pre.41" in macOS):

โœ… WORKS

v10.13.0 (LTS: Dubnium)
v10.14.0 (LTS: Dubnium)
v10.14.1 (LTS: Dubnium)
v10.14.2 (LTS: Dubnium)
v10.15.0 (LTS: Dubnium)
v10.15.1 (LTS: Dubnium)
v10.15.2 (LTS: Dubnium)
v10.15.3 (LTS: Dubnium)

โŒ NOT WORKS

v10.16.0 (LTS: Dubnium)
v10.16.1 (LTS: Dubnium)
v10.16.2 (LTS: Dubnium)
v10.16.3 (Latest LTS: Dubnium)
v12.0.0
v12.1.0
v12.2.0
v12.3.0
v12.3.1
v12.4.0
v12.5.0
v12.6.0
v12.7.0
v12.8.0
v12.8.1
v12.9.0

look 2019-05-28, Version 10.16.0 'Dubnium' (LTS), @BethGriggs, Is it related to ICU or libuv?

Sorry, I found out that the Express.js project is working fine after minimizing the test, but the Nest.js project is very slow.

I tried to debug and found that just deleting node_modules/ts-node-dev/lib/index.js L64 watcher.removeAll() is normal. Continue to delve into the debug discovery is actually: Here's the problem.

// node_modules/filewatcher/index.js

FileWatcher.prototype.remove = function(file) {
  var watcher = this.watchers[file]
  if (!watcher) return

  delete this.watchers[file]
  watcher.close()     <---- Here in Node.js 12 is very SLOW.
}

minimizing test use nest/tree/master/sample/01-cats-app.

tsd-v3 2019-08-23 14_06_55

This is an issue in other packages too - exactly the same scenario using socket-cluster and express. Unsure of the actual culprit, but it runs fine using node and ts-node v12, but when you add ts-node-dev to the mix you cant use to any version > v10.15.3 - it just hangs on startup. No errors thrown. FWIW, only devs on macOS impacted, Windows and Ubuntu devs are working fine.

This is beyond frustrating!

Filed an issue: https://github.com/nodejs/node/issues/29949, thanks @SolidZORO for debugging.
(it has nothing to do with this module or the filewatcher module.)

Though, perhaps as Solid mentioned - this module could avoid removing watchers if it doesn't have to?

For those affected by this, I would suggest using --no-deps if you can. I'm not sure why this is on by default, perhaps with the 1.0.0 release the author has an opportunity to change that ๐Ÿ˜„

@jonjaques I refer to this https://github.com/whitecolor/ts-node-dev/issues/51#issuecomment-490764844 and it works fine on node.js v12.13.0.

finally solved the problem. ๐Ÿ˜„

// package.json

"dev-tsnodedev": "NODE_ENV=development ts-node-dev --respawn --transpileOnly --ignore-watch node_modules -r tsconfig-paths/register ./src/main.ts",
Was this page helpful?
0 / 5 - 0 ratings