Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 1 commit into from
Jun 12, 2020

Conversation

rchiodo
Copy link

@rchiodo rchiodo commented Jun 12, 2020

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.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@@ -277,7 +278,15 @@ export class JupyterSessionManager implements IJupyterSessionManager {
cookieString,
allowUnauthorized
// tslint:disable-next-line:no-any
) as any
) as any,
Copy link
Member

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.

@rchiodo
Copy link
Author

rchiodo commented Jun 12, 2020

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)

Copy link

@DonJayamanne DonJayamanne left a 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.

@rchiodo rchiodo merged commit aeab323 into master Jun 12, 2020
@rchiodo rchiodo deleted the rchiodo/isolate_node_fetch branch June 12, 2020 16:07
@lock lock bot locked as resolved and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants