-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
setTimeout cannot be util.promisify'ed #13654
Comments
👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can. To help make it easier for us to investigate your issue, please follow the contributing guidelines. |
does electron 1.8.4 include a new enough node? You might want to use pify instead. |
This works in |
@pronebird you are correct. {
"http_parser": "2.7.0",
"node": "8.2.1",
"v8": "5.9.211.38",
"uv": "1.13.1",
"zlib": "1.2.11",
"ares": "1.10.1-DEV",
"modules": "57",
"openssl": "1.0.2l",
"electron": "1.8.4",
"chrome": "59.0.3071.115",
"atom-shell": "1.8.4"
} And yes, Node.js v8.2.1 already supports custom promisifying |
@gabmontes what happens if you print out You know what, that's weird. Broken in Electron v2.0.5 interactive shell (node v8.9.3):
Works in node v8.11.2
I think some of the custom promisify handlers haven't been properly set in Electron. It's also possible that it was a bug that was fixed in some patch release between node v8.9.3 and v.8.11.2. I don't really have any older node to verify that, but I think you have a clue how to workaround this for the time being. |
@pronebird Node.JS works fine. I have tested that in several versions as 8.2.1 (to match Electron 1.8.4) and 8.11.x (LTS). But in Electron, the required property of
Since it is not set, |
This sounds really similar to #13458. |
@davidcornu for sure both issues have the same root cause! |
@gabmontes Electron specific code is intercepting |
Expected Behavior
require('util').promisify(setTimeout)(delay).then(callback)
should work as per Node.JS 8.x docs.Actual behavior
"callback" argument must be a function
error is thrown inside promisifiedsetTimeout
.To Reproduce
Execute this in the main process:
It will throw the mentioned error.
Additional Information
The problem seems to be that
setTimeout[util.promisify.custom]
is not defined. Thereforeutil.promisify
tries to promisifysetTimeout
as a standard callback-last function but it is a special-case callback-first one.See:
https://nodejs.org/api/timers.html#timers_settimeout_callback_delay_args
https://nodejs.org/api/util.html#util_custom_promisified_functions
Haven't tested in v2.x or higher yet. Is there plans to eventually backport a fix for this to the 1.x versions?
Thanks!!
The text was updated successfully, but these errors were encountered: