-
Notifications
You must be signed in to change notification settings - Fork 231
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
Check for existence of process
object (fix for v2)
#413
Conversation
@mcollina @calvinmetcalf is there a chance you could look at it? |
Sorry for the long delay! The change in itself looks fine, however we need something slightly different for this to be released. This library currently is extracted from node core (version 10) via a series of scripts in the build/ folder. Would you mind tweaking this build step to apply these changes? It would need a test as well. Would you mind adding it in test/browser? Thanks! |
@mcollina Done.
I'm not sure what exactly to test. Also, I couldn't find a place where browser tests are actually being started - |
@th0r regarding browser tests: in CI we're doing |
@vweevers as I noted in PR description it's a fix for |
Ah sorry, I missed that, nevermind me then :) |
Is this not needed in v3? |
You could try |
@vweevers yes, it works (and they are all green) but do you run browser test at all on CI for v2? |
And another thought: maybe you could create a public |
At that time |
Well, all existing tests pass in Chrome v75 / FF 67 / Safari 12.1.1 |
I still did not get an answer to: #413 (comment)
|
Can @vweevers's comment and my comment be treated as an answer? |
Not at all. Does readable-stream v3 suffer from the same issue? I'm not keen on having the two versions diverge in behavior. |
According to this line it does: readable-stream/lib/_stream_readable.js Line 609 in 4ba93f8
I can fix it in a separate PR. |
process
objectprocess
object (fix for v2)
let's do that, thanks! |
|
@mcollina Tried to do the same for v3 but seems like you're relying on All browser tests pass because airtap uses I'm not sure what to do. Even if we replace |
Assuming we want to do that (I have no opinion on it), then one way to run tests without a |
I would do that because webpack 5 will remove auto-polyfilling of Node internals/global objects by default including |
🙀 That's a scary move for the ecosystem. For those reading along, see Automatic Node.js Polyfills Removed. |
So, we have 2 options:
Pros for №1:
Cons:
Pros for №2:
Cons:
|
-1 on changing behavior, for reasons mentioned in webtorrent/webtorrent#1568 (comment). To my understanding the webpack change is not final; perhaps some pushback is in order. |
@vweevers if I understand you correctly, you don't want to add a spec-compliant dependency to polyfill |
Just to clarify this issue, because it's still not clear to me. Is this problem happening only with Webpack v5? Or is this happening in some other cases? If current browserify and webpack inject process, how could you have ended up with this bug?
I think we should create a tiny |
Both |
I think it should be possible to configure airtap to not expose the process object. So we can test this in v3. |
Yes, it's possible by adding these lines to browserify:
- options:
detectGlobals: false
insertGlobals: false But in this case readable-stream/test/browser.js Lines 1 to 12 in 4ba93f8
If I remove them it fails with the same readable-stream/test/browser.js Line 13 in 4ba93f8
Here is the whole "require chain": test/browser.js => tape => through => stream-browserify => [email protected] (yes, exactly this library 😁) => safe-buffer => buffer .
If I add So, I'm out of ideas how to make browser tests work without polyfilling Node.js globals and seems like |
Seems like this package also relies on the readable-stream/lib/_stream_writable.js Line 70 in 4ba93f8
Currently it works because webpack provides polyfills for them automatically but it will break in webpack 5. |
I suggest to split this discussion, because supporting an undefined |
Can we get a similar PR for v3 (even without tests)? |
Shall I borrow webpack's implementation? It's quite primitive... |
I don't understand the question. This PR is not borrowing anything from Webpack. |
This PR didn't need to replace usages of |
I don't understand why. |
Because v2 used |
|
Appears that I can do the following: For v2:
module.exports = {
nextTick: nextTick
};
function nextTick(fn) {
var args = Array.prototype.slice.call(arguments, 1);
setTimeout(function () {
fn.apply(null, args);
}, 0);
}
{
"browser": {
"process-nextick-args": "./process-browser.js"
}
} For v3:
{
"browser": {
"./process": "./process-browser.js"
}
} @mcollina thoughts? |
I think it's cleaner to add Does it make sense? |
Why do we need this |
True, it's not needed. |
@mcollina may I expect it to be merged and published or shall I better search for another solution to my problem? |
Sure thing, it’s sitting in my list of things to do. I had to take some unexpected time off recently and I’m falling behind. |
@mcollina any news? |
Any ETA when this can be merged? |
@@ -54,7 +54,7 @@ function CorkedRequest(state) { | |||
/* </replacement> */ | |||
|
|||
/*<replacement>*/ | |||
var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick; | |||
var asyncWrite = typeof process !== 'undefined' && !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a problem with process.version
also undefined, so && typeof process.version !== 'undefined'
check also suggested, fyi nativescript is the environment
Fixes #412
Notes:
This PR fixes v2 and was branched from
v2.3.6
tag so it would be great to shipv2.3.7
with this fix.