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

Does not work after upgrading to 4.0.0 #480

Closed
lednhatkhanh opened this issue Dec 11, 2017 · 16 comments
Closed

Does not work after upgrading to 4.0.0 #480

lednhatkhanh opened this issue Dec 11, 2017 · 16 comments
Labels

Comments

@lednhatkhanh
Copy link

ts-node just suddenly stop working after upgrading to 4.0.0 (The same with 4.0.1):

nodemon.json

{
	"watch": ["src"],
	"ext": "ts",
	"ignore": ["src/**/*.spec.ts"],
	"exec": "ts-node -P ./tsconfig.json --no-cache ./src/index.ts"
}

tsconfig.json

{
	"compilerOptions": {
		"target": "esnext",
		"module": "commonjs",
		"sourceMap": true,
		"lib": ["esnext"],
		"outDir": "build",
		"rootDir": "src",
		"importHelpers": true,
		"noEmitOnError": true,
		"strict": true,
		"noUnusedLocals": true,
		"noUnusedParameters": true,
		"noImplicitReturns": true,
		"noFallthroughCasesInSwitch": true,
		"moduleResolution": "node",
		"experimentalDecorators": true,
		"emitDecoratorMetadata": true
	}
}

nodemon: 1.12.5 (dev dependency)
typescirpt: 2.6.2 (dev dependency)
ts-node: 4.0.1 (dev dependency)

Reverted ts-node back to 3.30 solved the problem.

@fox1t
Copy link

fox1t commented Dec 12, 2017

Hi, i have the same problem when using ts-node >= 4.x.x. When i save a file, node process isn't killed and both dev port and inspector port remains used. If i downgrade to 3.x.x, it starts working again. I use this npm scripts to start in dev mode:
"nodemon": "nodemon -e ts -w \"./src\" -x \"npm run debug\"",
"debug": "ts-node --inspect ./src/index.ts",

@unlight
Copy link

unlight commented Dec 12, 2017

Possible duplicate #481

@blakeembrey
Copy link
Member

blakeembrey commented Dec 14, 2017

Can you share the OS or other information so someone can help debug?

@fox1t
Copy link

fox1t commented Dec 14, 2017

macOS: 10.13.2
nodemon: 1.12.5 (dev dependency)
typescirpt: 2.6.2 (dev dependency)
ts-node: 4.0.1 (dev dependency)

I haven't spare time to debug at the moment , otherwise i could do it and post even more info.

@blakeembrey
Copy link
Member

Interesting, thanks. I thought it may have been a duplicate of #481, but not if it's on mac. Looks like these issues may be negative side effects of #419.

For anyone running into this, can you switch to using node -r ts-node/register? This avoids many of the process issues that were occurring and is likely the recommended way to use in the next release.

@unlight
Copy link

unlight commented Dec 14, 2017

node v8.9.0 Win8.1x64 node -r ts-node/register works for me.

@stelcheck
Copy link
Contributor

@blakeembrey just switched on my windows machine and everything seems to work fine when I rebuild from master on the repo. I do run into this issue when installing from NPM however.

@blakeembrey
Copy link
Member

@stelcheck That's really odd, there shouldn't be a difference between what's on master. Can you diff your built files at all? Maybe something in my release pipeline broke, that would be odd.

@stelcheck
Copy link
Contributor

Never mind, I was able to reproduce the issue locally.

There seems to be two issues: one related to how early errors are piped through on Windows (maybe mac?), the other I am still investigating. Trying to get a PR in ASAP.

@k8w
Copy link

k8w commented Dec 15, 2017

@blakeembrey Also not work after upgrade 4.0.1

OS: Win10
Node: 8.9.1

@stelcheck
Copy link
Contributor

The cause of the issue appears to be that process.stdin/out/err cannot be inherited by spawned processes on Windows. I couldn't find a solid reference to that issue, but that's the only thing that seems to be different.

That explains both why nothing gets printed out (the error happens in the subprocess, and its stdout/err is not piped to the main process), but also explains the actual crash (stdin is not a TTY, and no file names are being passed, so the code tries to read... nothing)

Since the reason that happens on Windows is because of a fix that was made essentially for *nix system, I'd say the simplest solution would be to not run in detached mode on Windows. I'll make a PR for that right now.

@stelcheck
Copy link
Contributor

Addendum: I suspect there might be something going on when using ts-node as a sub-process as well. (which would explain issues on macOS). I'll reboot on Linux soon and will check that as well.

@stelcheck
Copy link
Contributor

Just double-checked on Linux:

echo "process.on('SIGINT', () => console.log('called')); setInterval(() => console.log('sadasd'), 1000)" | node dist/bin.js

This seems to work properly. @fox1t is it possible that you also catch 'SIGTERM' in your app? You might also want to look into configuring a specific signal for nodemon remy/nodemon#725 89 (been a while I haven't used it, assuming this is still configurable).

@stelcheck
Copy link
Contributor

@fox1t Also, I see this issue in nodemon's issue tracker: remy/nodemon#1164 - the reporter is on Windows, but perhaps it is related to your issue as well?

@stelcheck
Copy link
Contributor

Here is another PR which would also solve the issue by simply removing subprocesses overall: #499

@ricardasjak
Copy link

ricardasjak commented Dec 21, 2017

Same problem here after upgrade from 3.3.0 to 4.0.2
Windows 10,
Node 9.2.0

However it works fine on CI (unix) build server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants