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

Docs: Cannot add agent option in fetch() call #43354

Closed
longzheng opened this issue Nov 25, 2022 · 1 comment · Fixed by #43374
Closed

Docs: Cannot add agent option in fetch() call #43354

longzheng opened this issue Nov 25, 2022 · 1 comment · Fixed by #43374
Labels
Developer Experience Issues related to Next.js logs, Error overlay, etc. TypeScript Related to types with Next.js.

Comments

@longzheng
Copy link
Contributor

longzheng commented Nov 25, 2022

What is the improvement or update you wish to see?

The current docs for "Disabling HTTP Keep-Alive" mentions it is possible to set the agent option in an individual fetch() call. However as of Next.js 13.0.4, this produces a type error.

The fetch type comes from the TypeScript lib.dom.d.ts which does not allow for specifying the agent because it is a client-side definition of fetch in the browser.

image

Repro: https://stackblitz.com/edit/vercel-next-js-bar5lp?file=pages/index.tsx

Is there any context that might help us understand?

I think the confusion arises because Next.js automatically polyfills node-fetch where the agent option is applicable, I'm not sure how TypeScript type could distinguish between the fetch being used on the server-side or client-side.

Does the docs page already exist? Please link to it.

https://nextjs.org/docs/api-reference/next.config.js/disabling-http-keep-alive

@longzheng longzheng added the Documentation Related to Next.js' official documentation. label Nov 25, 2022
@balazsorban44 balazsorban44 added TypeScript Related to types with Next.js. Developer Experience Issues related to Next.js logs, Error overlay, etc. and removed Documentation Related to Next.js' official documentation. labels Nov 25, 2022
longzheng added a commit to longzheng/next.js that referenced this issue Nov 25, 2022
Fixes vercel#43354

It is not possible to specify an `agent` on a single `fetch()` call since the types for `fetch` come from TypeScript where `agent` is not supported as an option.
@kodiakhq kodiakhq bot closed this as completed in #43374 Dec 19, 2022
kodiakhq bot pushed a commit that referenced this issue Dec 19, 2022
fixes #43354

It is not possible to specify an `agent` on a single `fetch()` call since the types for `fetch` come from TypeScript where `agent` is not supported as an option.
@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Developer Experience Issues related to Next.js logs, Error overlay, etc. TypeScript Related to types with Next.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants