Open waldekmastykarz opened 3 months ago
Thanks for the report! At this point, core enhancements won't be added to this library by the team. A PR would be reviewed though.
Also, could this be fixed with just docs? Very suboptimal, but could be an option.
Thoughts?
As far as I can tell, the only thing we need to change in the code is the type that defines fetch options, so that it includes the new dispatcher property. Other than that, we need to update docs and explain how to use it. The code itself works just fine.
Came across this problem on Node v20.11.1
we were using something similar to - https://learn.microsoft.com/en-us/graph/sdks/customize-client?tabs=typescript#configuring-the-http-proxy-for-the-client:
// Create a client with the proxy
const graphClient = Client.initWithMiddleware({
authProvider: authProvider,
fetchOptions: {
agent: proxyAgent,
},
});
This was giving us a fetch failed
error.
After reverse engineering things and reading through various posts we arrived at https://github.com/nodejs/undici/issues/1350#issuecomment-1137916129
As we are Js
and not Ts
, we have ended up with:
const graphClient = Client.initWithMiddleware({
debugLogging: true,
authProvider,
fetchOptions: {
dispatcher: new ProxyAgent({
uri: proxyUrl,
keepAliveTimeout: 10,
keepAliveMaxTimeout: 10
})
}
})
Thought this might help someone in the future.
Bug Report
Description
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):
What's noteworthy:
We should update our FetchOptions interface to support specifying dispatcher.
Console Errors: no
Steps to Reproduce
Expected behavior: web requests intercepted by the specified proxy
Actual behavior: web requests passed through without being intercepted
Additional Context
Usage Information
SDK Version - 3.06