-
Notifications
You must be signed in to change notification settings - Fork 122
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
Forwarding signals correctly to child process #269
Conversation
@wclr is there perhaps another contributor with permissions that I could get review from? Thanks! |
@wclr bump -- would be great to get this in! |
@wclr would it be possible to merge this too? Just saw your activity on the other PR. |
@anthonyalayo did you run tests on it manually? There are currently problems with travis CI integration here. I've been in a haste to merge this one, tests are not passing on my machine. |
@wclr yeah I unfortunately had issues running the travis tests on my machine so I tested it all manually. Were they able to be resolved? If not I can try getting it going on my local, let me know. |
It is not the travis tests its just tests. That are supposed to run -) Such things especially should not be developed without tests. After merging your PR tests are not passing. I've added build step. Try to run tests (yarn test) before merging your PR and after. |
Great thanks @wclr let me take a look |
Yeah I see the test fail difference on the previous commit versus the merge, will have a fix tonight. |
@wclr can you share your launch.json? Since the project uses chai and mocha instead of jest, I can't simply run jest runner and throw in breakpoints. |
What launch.json? I don't use debuggers with breakpoints. You may just analyze the changes you made and then apply them in steps. There is also |
@wclr for something of this caliber, proper debugging is necessary. I have attempted attaching debuggers to the forked processes, but no luck. I have attempted to have the child processes print to stdout/stderr, but no luck. Inside the process event handlers, nothing prints. I have seen far and wide that this is behavior on NodeJS. I cannot for the life of me get any vector of debuggability of this working, so I will have to give up on this. I have code that relies on a graceful shutdown in order to clean up connections, like so:
And without the fix that is reflected inside ts-node in TypeStrong/ts-node#419, the graceful shutdown won't occur. The current code does not wait for the child process to exit, it kills the parent earlier:
Unfortunately I'm at my wits end with the lack of debuggability, so I will just place a bounty in the issues section. |
First, why not just add a failing test for the case? Then I could look a what is going on. |
@wclr sorry, could you clarify? A majority of the tests were failing, so any of those would be useful for investigating? For example, I was attempting to debug the issue using this test: Unfortunately as I noted earlier, it was very difficult to debug for me as I had no success at getting logs or breakpoints in the child processes. If there is anything I can do to make it more debug friendly, please let me know. For the record, I still believe these changes are worth it. I just sanity tested my changes again running Without my fix (current master)
However with my changes, it properly closes the connection:
I ran the deployment process a few time for sanity. A new container is coming up, while the old container successfully closes the database connections. |
I mean narrow down the issue and add failing test for your case here: https://github.com/wclr/ts-node-dev/blob/master/test/tsnd.test.ts#L42 |
@wclr unfortunately that is the issue, I was not able to narrow down it down. So I was using the simplest test there as an example. |
This comment was marked as spam.
This comment was marked as spam.
@wclr I tried for about 5 hours, but no luck. I would need some help to sink more time into it. If you could help, that would be greatly appreciated.
I can do this, it would be a docker container, a barebones NodeJS server, and skaffold to run kubernetes locally. However, I dont know what value it would provide. I have logs showing the difference in behaviour, and I have my fork of the project which shows the fixed behaviour.
To be fair, the issue is not unknown. It also occured in |
Did this ever get anywhere, I'm running into some issues because |
Summary
While using both
ts-node-dev
andts-node
fordevelopment
andproduction
, I noticed thatts-node-dev
was not properly waiting for my child process to finish before exiting. This support was already added tots-node
here: TypeStrong/ts-node#419Here's an example run after the changes:
> ts-node-dev --debug --transpile-only src/index.ts
@wclr let me know what I need to do to get this into our next release. Thanks!