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

Unable to set the fetch agent #185

Open
PhilHannent opened this issue Sep 12, 2021 · 1 comment
Open

Unable to set the fetch agent #185

PhilHannent opened this issue Sep 12, 2021 · 1 comment

Comments

@PhilHannent
Copy link

Steps to Reproduce

To make use of socket reuse via HTTP keep alive's , we have been setting the agent on our fetch requests and using the library to help:

https://www.npmjs.com/package/agentkeepalive

As per this documentation recommendation:
https://docs.microsoft.com/en-us/azure/app-service/troubleshoot-intermittent-outbound-connection-errors#avoiding-the-problem

Observed Behaviour

The typescript compiler is complaining that:

Argument of type '{ agent: HttpAgents; }' is not assignable to parameter of type 'OmitStrict<RequestInit, "method">'. Object literal may only specify known properties, and 'agent' does not exist in type 'OmitStrict<RequestInit, "method">'

Expected Behaviour

The getPhotos and photos.get accept and use the agent parameter.

@OliverJAsh
Copy link
Member

How do you do this when you use fetch? The functions exported by this package just forward the options through to fetch.

The agent property doesn't seem to exist when we use fetch:

fetch('https://httpbin.org/get', { agent: {} })

https://www.typescriptlang.org/play?#code/GYUwLgxgFgFA5FMYAOBnAXAek4lAjASwDsA6AewCcBzTK8OAGgAIBvJgQzqLHVYF8mfAJRA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants