Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants