-
-
Notifications
You must be signed in to change notification settings - Fork 533
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
Segfault with AsyncLocalStorage and process.exit #1380
Comments
To clarify my request, I think the segfault happens within Node.JS. Unfortunately just running the transpiled code under node does not crash, so I'm looking forward to produce a minimal under native node (not using large dependencies such as ts-node, etc.). This amounts to identifying the code pattern within ts-node that in conjunction with my code, yields to the crash. Is there some doc on ts-node's design or could someone point to the relevant places to look at in the sources ? |
Interesting, I can point you to all the places where we are hooking into Everything mentioned here is for our CommonJS loader, not our new ESM loader which uses a different set of hooking APIs. Your reproduction is using our CommonJS loader. In the information below, I mention ways that you can modify We install a third-party dependency called We hook into the module loading process here:
Internally it uses TypeScript's APIs. The first time you compile a file, it will need to do a lot of CPU work because that's the way typescript works: it needs to load lots of declaration files, it may need to load a bunch of Our CLI also does a few tricks to make sure the execution environment looks correct to whatever script we are running.
This will still install I hope this helps, best of luck! |
Could it be related to this? nodejs/node#39019 |
Thanks a lot. Honestly I was not hopping to get a response so fast and with so many actionable details. Really appreciate it 👍 I'll definitely have a closer look as soon as I find some time. From a quick glance the discussion at nodejs/node#39019 seems to be about at least two issues, one of which is fixed in master, the other apparently not, and also a bit random. Stack traces are similar. I guess I'll start with trying to reproduce with |
I'm doing housekeeping and I think I can close this issue. If this turns out to be a ts-node bug, we can reopen it or file a new bug report. |
Expected Behavior
Should not segfault :)
Native node doesn't segfault running the same code, and tsc doesn't segfault compiling the code, so it must be inside ts-node, although ultimately it might be a Node.JS bug ? If so I may need some help gathering more info before submitting upstream.
Actual Behavior
segmentation fault
Steps to reproduce the problem
Running my code with ts-code randomly segfault half the time when I have a failing unit test. I managed to reduce from ~5k lines to a minimal test case, but it segfaults less often.
Minimal reproduction
repro PR
segfault.ts
:And then run with:
The loop break when it segfaults at
v8::Context::setPromiseHooks
:Specifications
ts-node version: 10.0.0
node version: 16.3.0
TypeScript version: 4.3.2
tsconfig.json, if you're using one: (none)
Operating system and version: Linux 5.12.10 x64 (ArchLinux), libc 2.33
The text was updated successfully, but these errors were encountered: