Unable to set the fetch agent
PhilHannent opened this issue · 1 comments
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.
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: {} })