-
Notifications
You must be signed in to change notification settings - Fork 29.1k
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
Promisify crashing node (or making it hang) #49607
Comments
That's really surprising, I'm getting exit code 13, can you double check if you're seeing an exit code 0? |
I can, one sec. Edit: hmm, you are right, this reproduction is code 13, looking into source repo to see if it might be 13 there as well. |
The same code crashing in the code I linked above (semantic-release/commit-analyzer#525) exits with code I for sure can't catch whatever error is happening (I tried).
|
Assuming you are seeing an exit code of 13, then it's the expected and documented behavior: Lines 3929 to 3930 in 718981e
What's happening is that import { promisify } from "node:util";
const asyncFunction = async (callback) => callback(null, 5);
await promisify(asyncFunction)();
console.log('This does show');
An async function is indistinguishable from a sync function, I don't think there's a reliable way for the runtime to detect if the passed function is async or not. Maybe a linter could catch it though |
I'll look a bit further. I'm not sure the mistakes you point out mean there is no bug, or my reproduction is simply wrong... |
PR-URL: #49609 Fixes: #49607 Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: nodejs#49609 Fixes: nodejs#49607 Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
Version
v20.6.1
Platform
Linux xxx 6.2.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Mon Aug 14 13:42:26 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
Run this code:
How often does it reproduce? Is there a required condition?
Every time
What is the expected behavior? Why is that the expected behavior?
Anything but a silent crash... if it's not allowed throw an error, if you do accept async functions maybe promisify should be a noop since async functions already return promises...
I'm no node developer
What do you see instead?
Status code 0, process exits.
Additional information
This bug breaks packages like this: semantic-release/commit-analyzer#525
The text was updated successfully, but these errors were encountered: