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

Specifying http proxy changed in Node@18 and 20 #1103

Open
waldekmastykarz opened this issue Mar 11, 2024 · 3 comments
Open

Specifying http proxy changed in Node@18 and 20 #1103

waldekmastykarz opened this issue Mar 11, 2024 · 3 comments
Assignees
Milestone

Comments

@waldekmastykarz
Copy link

Since v18, Node ships with a native fetch client. This client requires a different way to specify an HTTP proxy than what we've been supporting in our SDKs so far.

To specify an HTTP proxy for Node's fetch, you need to use the following code (tested on Node v18.19 and v20.11):

import { ProxyAgent } from 'undici';
import { Client } from '@microsoft/microsoft-graph-client';

const dispatcher = new ProxyAgent(process.env.https_proxy);
const fetchOptions = {
  dispatcher
};

Client.initWithMiddleware({
  middleware,
  fetchOptions
});

What's noteworthy:

  • we specify HTTP proxy using dispatcher instead of agent (agent is ignored on requests, which makes it hard to debug)
  • the ProxyAgent dispatcher comes from undici which seems to be maintained by Node folks. The ProxyAgent is incompatible with other agents that we used to use in the past.

We should update our FetchOptions interface to support specifying dispatcher.

@baywet
Copy link
Member

baywet commented Mar 11, 2024

Thanks for reaching out.

@sebastienlevert and I were chatting about that earlier and he mentioned he made it work. I'll let him provide the specifics when he has time (as you know I'm traveling right now and don't have time to dig into this)

@baywet baywet added this to the Backlog milestone Mar 11, 2024
@sebastienlevert
Copy link

Just to confirm... This is for Graph JS v3, right? We donc have the middleware initialization anymore IIRC.

As we won't be adding new features over there, I highly doubt we'll get to this.

@waldekmastykarz
Copy link
Author

This change affects any code that relies on Node's fetch. I noticed it in Graph JS SDK v3 but if the new TypeScript SDK also uses Node.js fetch, then it would also have the same issue.

@fey101 fey101 removed the question label Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo 📃
Development

No branches or pull requests

4 participants