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

Bluebird fails to load in a nwjs (nodewebkit) app #525

Closed
NervosaX opened this issue Mar 12, 2015 · 7 comments
Closed

Bluebird fails to load in a nwjs (nodewebkit) app #525

NervosaX opened this issue Mar 12, 2015 · 7 comments

Comments

@NervosaX
Copy link

It gives me the error:

[23637:0312/105955:INFO:CONSOLE(81)] "Uncaught TypeError: Cannot read property 'isStatic' of undefined", source: file://.../dist/jspm_packages/npm/bluebird@2.9.10/js/browser/bluebird.js (81)
[23637:0312/105955:ERROR:nw_shell.cc(335)] Error evaluating file://.../dist/jspm_packages/npm/bluebird@2.9.10/js/browser/bluebird.js
Uncaught TypeError: Cannot read property 'isStatic' of undefined
[23637:0312/105955:INFO:CONSOLE(2237)] "Uncaught Error evaluating file://.../dist/jspm_packages/npm/bluebird@2.9.10/js/browser/bluebird.js
Uncaught TypeError: Cannot read property 'isStatic' of undefined", source: file://.../dist/jspm_packages/system.src.js (2237)

I've shortened the filenames for readability.

I can confirm that it worked fine in bluebird version 2.9.3, but I'd say that after commit 98b0252 the issue occurred.

Reading over the code in that commit, it seems to be because
typeof window === "undefined"
isn't part of the isNode check. If I add this line manually then my application runs.

@petkaantonov
Copy link
Owner

Try with at least 2.9.6+

@NervosaX
Copy link
Author

2.9.6 works. 2.9.13 fails.
I tried every version between 2.9.7 and 2.9.13 and each failed.

@petkaantonov
Copy link
Owner

Does node webkit delete the global setImmediate function or something? That's what's being undefined ... that or process nextTick?

What does process.versions.node say in nw?

@NervosaX
Copy link
Author

It gives me: "1.2.0"

@petkaantonov
Copy link
Owner

That means global.setImmediate is undefined, why does nw delete it?

@NervosaX
Copy link
Author

I found this old commit for nw.js nwjs/nw.js#897

Sure enough if I add this line, bluebird will work.

if (typeof global !== "undefined") {
    window.setImmediate = global.setImmediate;
}

That's pretty unfortunate, as I'm not sure if it should be bluebird's problem to deal with that sort of issue.

@petkaantonov
Copy link
Owner

Well promises should always use nextTick anyway, I am not sure what the reason for the check even was originally. setImmediate is macro task.

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

2 participants