-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Isolate node fetch for jupyter to use our own #12304
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
Conversation
Kudos, SonarCloud Quality Gate passed!
|
@@ -277,7 +278,15 @@ export class JupyterSessionManager implements IJupyterSessionManager { | |||
cookieString, | |||
allowUnauthorized | |||
// tslint:disable-next-line:no-any | |||
) as any | |||
) as any, |
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.
Seems legit. We should make sure to check (I'll note it in the associated issue) password connections since that was doing some manual manipulations with fetch.
I'm still a little iffy on why this was happening in the first place. Why was jupyter's node-fetch coming from the other package? Shouldn't node isolate these things? I verified in the debugger that doing this means jupyter is actually using ours, but I'm not 100% sure webpack isn't messing something up here. It might just be working because the version matches now (I tested the vsix too) |
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'm still a little iffy on why this was happening in the first place. Why was jupyter's node-fetch coming from the other package? Shouldn't node isolate these things?
This I believe was because jupyter gives preference to any globally registered node-fetch
. I.e. if global.fetch
is registered, then it would use that.
see here
// Mangle the require statements so it does not get picked up in the
// browser assets.
/* tslint:disable */
let fetchMod = require('node-fetch');
FETCH = global.fetch || fetchMod;
REQUEST = global.Request || fetchMod.Request;
HEADERS = global.Headers || fetchMod.Headers;
WEBSOCKET = global.WebSocket || require('ws');
Now that we've overridden it in settings, it should always use the one prescribed by us.
Not sure updating node_fetch
is necessary, but that doesn't hurt.
For #11830
The version of node-fetch that jupyter uses isn't compatible with other versions. Forcing it to use our global one seems to fix the problem.