Ts-node-dev: Application fail to respawn after file modification has been detected

Created on 10 Jan 2021  Â·  20Comments  Â·  Source: wclr/ts-node-dev

Issue description

The application fails to respawn after a few restarts:
command :

cross-env NODE_ENV=development ts-node-dev --debug --files --respawn --project tsconfig.json --transpile-only --inspect --watch .env,../common/src, -- src/devIndex.ts

INFO] 17:58:00 Restarting: ../app/src/langConsts.ts has been modified
[DEBUG] 17:58:00 ../snip_common/src/langConsts.ts compiled in 184 ms
[DEBUG] 17:58:00 Removing all watchers from files
[DEBUG] 17:58:00 Child is still running, restart upon exit
[DEBUG] 17:58:00 Disconnecting from child
[DEBUG] 17:58:00 Sending SIGTERM kill to child pid 79198
[2021-01-09T17:58:00.471] [INFO] expressApp.ts - Shutting down...
About to exit with code: 143
Assertion failed: (napi_create_string_utf8(env, events->events[idx].path, NAPI_AUTO_LENGTH, &args[0]) == napi_ok), function fse_dispatch_event, file ../src/fsevents.c, line 147.
npm ERR! code 1
npm ERR! path /Users/bobbui/Documents/app/packages/backend
npm ERR! command failed
npm ERR! command sh -c cross-env NODE_ENV=development ts-node-dev --debug --files --respawn --project tsconfig.json --transpile-only --inspect --watch .env,../common/src,  -- src/devIndex.ts

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/bobbui/.npm/_logs/2021-01-10T01_58_00_658Z-debug.log

I think the most relevant part is Assertion failed: (napi_create_string_utf8(env, events->events[idx].path, NAPI_AUTO_LENGTH, &args[0]) == napi_ok), function fse_dispatch_event, file ../src/fsevents.c, line 147.

but a quick Google search returns absolutely nothing 😢

Context

OS version (is it docker or host?), ts-node-dev version
Mac OS 10.15.7
[email protected]
node v15.4.0
Did you try to run with ts-node?
yes
Did you try to run with --files option enabled?
yes
Did you try to run with --debug option enabled?
yes
Do you have a repro example (git repo) with simple steps to reproduce your problem?
no

Most helpful comment

There were reports on this https://github.com/wclr/ts-node-dev/issues/241 not sure what it may be caused by. This also probably affects MacOs users. Try to use --poll option.

All 20 comments

@bobbui I feel your pain. As temporary workaround I rolled back from 1.1.1 to 1.1.0, problem gone.

@bobbui I feel your pain. As temporary workaround I rolled back from 1.1.1 to 1.1.0, problem gone.

Revert to 1.1.0 does not work for me.

There were reports on this https://github.com/wclr/ts-node-dev/issues/241 not sure what it may be caused by. This also probably affects MacOs users. Try to use --poll option.

Assertion failed: (napi_create_string_utf8(env, events->events[idx].path, NAPI_AUTO_LENGTH, &args[0]) == napi_ok), function fse_dispatch_event, file ../src/fsevents.c, line 147.

I caught that error after upgrading my storybook (npx sb upgrade). It's weird, because there is no ts-node in my dependency tree.

Same here within a nuxt(https://nuxtjs.org/) project. I had to upgrade a few dependencies, but nothing really crucial and since today it's randomly throwing those errors while being in watch mode for compilation. Upon some changes everything's compiling just fine, sometimes it pops up out of the blue. Haven't noticed any pattern.

Assertion failed: (napi_create_string_utf8(env, events->events[idx].path, NAPI_AUTO_LENGTH, &args[0]) == napi_ok), function fse_dispatch_event, file ../src/fsevents.c, line 147.

@bobbui I feel your pain. As temporary workaround I rolled back from 1.1.1 to 1.1.0, problem gone.

Revert to 1.1.0 does not work for me.

Reverting also didn't work for me. After the error my CPU usage remains high (can see a 100% node instance in Activity Monitor)

Same issue for me. I want to mention this that the port continues to stay open on my server and I have to look up the PID and kill it manually every time this happens (pretty awful DX)

Using Node 14.15.4
Big Sur 11.1

"NODE_ENV=local ts-node-dev --debug --transpile-only --respawn ./src/index.ts",

info: App > 🚀 Server ready at http://localhost:7765/graphql {"label":"common-express.cjs.development.js","system":"local-idp-profile-service","pid":19784,"host":"maxwellsmacbook.lan","timestamp":"2021-01-15T19:47:21.259Z"} [INFO] 14:47:28 Restarting: /Users/maxwell.krause/dev/local-idp-profile-service/src/gql/typeDefs/Address.ts has been modified [DEBUG] 14:47:28 /Users/maxwell.krause/dev/local-idp-profile-service/src/gql/typeDefs/Address.ts compiled in 7 ms [DEBUG] 14:47:28 Removing all watchers from files [DEBUG] 14:47:28 Child is still running, restart upon exit [DEBUG] 14:47:28 Disconnecting from child [DEBUG] 14:47:28 Sending SIGTERM kill to child pid 19784 [DEBUG] 14:47:28 Child exited with code 0 [DEBUG] 14:47:28 Starting child process -r /var/folders/x2/q8lst3254ygffgj503cxfjjw0000gr/T/ts-node-dev-hook-9205511574690581.js /Users/maxwell.krause/dev/local-idp-profile-service/node_modules/ts-node-dev/lib/wrap.js ./src/index.ts Assertion failed: (napi_create_string_utf8(env, events->events[idx].path, NAPI_AUTO_LENGTH, &args[0]) == napi_ok), function fse_dispatch_event, file ../src/fsevents.c, line 147. [1] 19471 abort npm run dev

I also see this which I haven't before, granted I am using this in conjuction with a graphql code generator named "nexus"

Error: write EPIPE at process.target._send (internal/child_process.js:832:20) at process.target.send (internal/child_process.js:703:19) at Object.exports.send (/Users/maxwell.krause/dev/local-idp-profile-service/node_modules/ts-node-dev/lib/ipc.js:17:14) at /Users/maxwell.krause/dev/local-idp-profile-service/node_modules/ts-node-dev/lib/wrap.js:88:9 at Object.nodeDevHook [as .ts] (/Users/maxwell.krause/dev/local-idp-profile-service/node_modules/ts-node-dev/lib/hook.js:61:17) at Module.load (internal/modules/cjs/loader.js:928:32) at Function.Module._load (internal/modules/cjs/loader.js:769:14) at Module.require (internal/modules/cjs/loader.js:952:19) at require (internal/modules/cjs/helpers.js:88:18) at Object.<anonymous> (/Users/maxwell.krause/dev/local-idp-profile-service/node_modules/ts-node-dev/lib/wrap.js:104:1)

There were reports on this #241 not sure what it may be caused by. This also probably affects MacOs users. Try to use --poll option.

This works well. Thanks @wclr

Any progress on this one? --poll works but is quite CPU intensive

This bug basically completely breaks this tool — is there anything we can do to help?

On the nuxt side of things it seems that this issue was solved through this: https://github.com/fsevents/fsevents/pull/356

Having this problem still. --poll flag and reverting to 1.1.0 did not work. Using: ts-node-dev ver. 1.1.0 (ts-node ver. 9.1.1, typescript ver. 3.9.7) 😢

I can confirm that. Even with --poll flag the problem persists. However, it does happen less frequently.

Try to upgrade.

Still having the same issue on v1.1.6.

Can confirm, still an issue:

[0] Assertion failed: (napi_create_string_utf8(env, events->events[idx].path, NAPI_AUTO_LENGTH, &args[0]) == napi_ok), function fse_dispatch_event, file ../src/fsevents.c, line 147.
[0] error Command failed with signal "SIGABRT".
[0] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[0] yarn start:dev exited with code 1
interrupt: 2
~/w/u/api:develop* λ yarn list ts-node-dev chokidar
yarn list v1.22.10
warning Filtering by arguments is deprecated. Please use the pattern option instead.
├─ [email protected]
└─ [email protected]

Same trouble here on 1.1.6. I was (as usual) suspecting the Docker file watches. But even when running this outside Docker (on macOS) the issue happens.

Any observations yet, if Is this issue introduced from node-dev or is it specific to ts-node-dev?

If you still have this issue on macOS it is likely related to fsevents

Version 2.3.2 or newer should fix it, see here: https://github.com/fsevents/fsevents/pull/356

Fix:

npm update fsevents

(I can confirm it works on my environment)

I have been trying version 2.3.2 of fsevents this afternoon, but for me the original issue still occurs. (macOS 10.15.7)

Still getting this issue
Assertion failed: (napi_create_string_utf8(env, events->events[idx].path, NAPI_AUTO_LENGTH, &args[0]) == napi_ok), function fse_dispatch_event, file ../src/fsevents.c, line 147.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sveyret picture sveyret  Â·  4Comments

DMCTowns picture DMCTowns  Â·  3Comments

danielpza picture danielpza  Â·  5Comments

timsuchanek picture timsuchanek  Â·  6Comments

Derya picture Derya  Â·  6Comments