Uh oh!
There was an error while loading. Please reload this page.
Check for existence of process object (fix for v2) - #413
Conversation
@mcollina@calvinmetcalf is there a chance you could look at it? |
mcollina
commented
Jun 29, 2019
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! |
th0r
commented
Jul 1, 2019
@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 |
th0r
commented
Jul 1, 2019
@vweevers as I noted in PR description it's a fix for |
vweevers
commented
Jul 1, 2019
Ah sorry, I missed that, nevermind me then :) |
mcollina
commented
Jul 1, 2019
Is this not needed in v3? |
vweevers
commented
Jul 1, 2019
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 |
th0r
commented
Jul 1, 2019
Well, all existing tests pass in Chrome v75 / FF 67 / Safari 12.1.1 |
th0r
commented
Jul 2, 2019
mcollina
commented
Jul 4, 2019
I still did not get an answer to: #413 (comment)
|
th0r
commented
Jul 4, 2019
Can @vweevers's comment and my comment be treated as an answer? |
mcollina
commented
Jul 4, 2019
Not at all. Does readable-stream v3 suffer from the same issue? I'm not keen on having the two versions diverge in behavior. |
th0r
commented
Jul 4, 2019
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)mcollina
commented
Jul 4, 2019
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 |
vweevers
commented
Jul 5, 2019
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 |
vweevers
commented
Jul 5, 2019
🙀 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:
|
vweevers
commented
Jul 5, 2019
-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 |
mcollina
commented
Jul 5, 2019
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 |
th0r
commented
Jul 5, 2019
Both |
mcollina
commented
Jul 5, 2019
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: falseinsertGlobals: falseBut 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 => readable-stream@2.3.6 (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. |
vweevers
commented
Jul 5, 2019
I suggest to split this discussion, because supporting an undefined |
mcollina
commented
Jul 5, 2019
Can we get a similar PR for v3 (even without tests)? |
th0r
commented
Jul 5, 2019
Shall I borrow webpack's implementation? It's quite primitive... |
mcollina
commented
Jul 5, 2019
I don't understand the question. This PR is not borrowing anything from Webpack. |
th0r
commented
Jul 5, 2019
This PR didn't need to replace usages of |
mcollina
commented
Jul 5, 2019
I don't understand why. |
th0r
commented
Jul 5, 2019
Because v2 used |
mcollina
commented
Jul 5, 2019
|
Appears that I can do the following: For v2:
module.exports={nextTick: nextTick};functionnextTick(fn){varargs=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? |
mcollina
commented
Jul 5, 2019
I think it's cleaner to add Does it make sense? |
th0r
commented
Jul 5, 2019
Why do we need this |
mcollina
commented
Jul 5, 2019
True, it's not needed. |
th0r
commented
Jul 8, 2019
@mcollina may I expect it to be merged and published or shall I better search for another solution to my problem? |
mcollina
commented
Jul 22, 2019
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. |
th0r
commented
Aug 2, 2019
@mcollina any news? |
kostos
commented
Aug 6, 2019
Any ETA when this can be merged? |
| /*<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.
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.6tag so it would be great to shipv2.3.7with this fix.