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

Fix undici warning in Node.js 18 #42477

Merged
merged 6 commits into from Nov 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 8 additions & 10 deletions packages/next/server/config.ts
Expand Up @@ -57,17 +57,15 @@ const experimentalWarning = execOnce(
}
)

export function setHttpClientAndAgentOptions(config: NextConfig) {
export function setHttpClientAndAgentOptions(config: {
httpAgentOptions?: NextConfig['httpAgentOptions']
experimental?: {
enableUndici?: boolean
}
}) {
if (isAboveNodejs16) {
if (
config.experimental?.enableUndici &&
!config.experimental?.appDir &&
isAboveNodejs18
) {
Log.warn(
`\`enableUndici\` option is unnecessary in Node.js v${NODE_18_VERSION} or greater.`
)
} else {
// Node.js 18 has undici built-in.
if (config.experimental?.enableUndici && !isAboveNodejs18) {
// When appDir is enabled undici is the default because of Response.clone() issues in node-fetch
;(global as any).__NEXT_USE_UNDICI = config.experimental?.enableUndici
}
Expand Down