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

Guard against falsey process.versions to support React Native #1542

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

L8D
Copy link
Contributor

@L8D L8D commented Jul 24, 2018

I ran into this issue when working on a React Native project. When I imported bluebird, it would throw Cannot read property 'node' of undefined and I had to work around the problem by using Object.defineProperty(process, 'versions', ...) to get bluebird to work.

Strangely, this "bug" only became a problem after using bluebird in the project for a month or so. I haven't hunted down the culprit but it is populating global.process with an [object process]

I'm not sure if this is really the correct change, since this logic effects whether setImmediate/process.nextTick is used, and we probably want to use setImmediate in a React Native environment.

@Ginden
Copy link
Contributor

Ginden commented Aug 21, 2018

I would suggest changing isNode, not isRecentNode.

@mlostekk
Copy link
Contributor

mlostekk commented Nov 14, 2018

This is blocking debugging with VSCode. @L8D how was your workaround looking like?

And why changing isNode? I mean it is actually node running. But this introduces an compatibility issue with vscode.

@sreevisakh
Copy link

I am getting the same error while using bluebird with react native.
RN: 0.57.5
Bluebird: 3.5.3

Is there anything I can do?

@mlostekk
Copy link
Contributor

I have fixed it temporarily like this

  1. Install node modules
  2. Open bluebird.js
  3. Modify the code for ret.isRecentNode to
ret.isRecentNode = ret.isNode && (function() {
    var version = process.version.split(".").map(Number);
    return (version[0] === 0 && version[1] > 10) || (version[0] > 0);
})();

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

Successfully merging this pull request may close these issues.

4 participants