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

v3.7.2 errors when setTimeout is not defined #1659

Open
agriffis opened this issue Sep 5, 2020 · 2 comments
Open

v3.7.2 errors when setTimeout is not defined #1659

agriffis opened this issue Sep 5, 2020 · 2 comments

Comments

@agriffis
Copy link

agriffis commented Sep 5, 2020

  1. What version of bluebird is the issue happening on?

v3.7.2

  1. What platform and version? (For example Node.js 0.12 or Google Chrome 32)

GraalVM JS 20.1.0 (ES2020 but without Node.js APIs)

  1. Did this issue happen with earlier version of bluebird?

No

Bluebird v3.7.2 throws an exception because setTimeout isn't defined. In v3.7.1 this didn't happen, presumably because of the check for typeof document === "object" etc.

org.graalvm.polyglot.PolyglotException: ReferenceError: setTimeout is not defined
	at <js>.deferUnhandledRejectionCheck(search.js:49866) ~[?:?]
	at <js>.Promise._ensurePossibleRejectionHandled(search.js:49888) ~[?:?]
	at <js>.Promise._reject(search.js:52887) ~[?:?]
	at <js>.Promise._rejectCallback(search.js:52677) ~[?:?]
	at <js>.Promise.rejected(search.js:52385) ~[?:?]
@agriffis
Copy link
Author

agriffis commented Sep 5, 2020

My mistake, this also happens in v3.7.1, I just thought it appeared in v3.7.2

@agriffis
Copy link
Author

agriffis commented Sep 6, 2020

After some more debugging, I found the error in my code leading to this. I had in one case:

const f = Promise.reject(new Error('foo'))

when I intended

const f = () => Promise.reject(new Error('foo'))

So at this point this issue is poorly titled and described, because it isn't related to the changes in v3.7.2.

Still, it seems like bluebird assumes that setTimeout will be available, but the JS environment might not provide it. Would it make sense to conditionalize the unhandled rejection check on the presence of setTimeout?

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

No branches or pull requests

1 participant