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

Ensure Undici is enabled for appDir in all cases #42382

Merged
merged 5 commits into from Nov 3, 2022
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions packages/next/server/config.ts
Expand Up @@ -65,9 +65,7 @@ export function setHttpClientAndAgentOptions(config: NextConfig) {
)
} else {
// When appDir is enabled undici is the default because of Response.clone() issues in node-fetch
;(global as any).__NEXT_USE_UNDICI = config.experimental?.appDir
? true
: config.experimental?.enableUndici
;(global as any).__NEXT_USE_UNDICI = config.experimental?.enableUndici
}
} else if (config.experimental?.enableUndici) {
Log.warn(
Expand Down Expand Up @@ -260,6 +258,10 @@ function assignDefaults(dir: string, userConfig: { [key: string]: any }) {
)
}

if (result.experimental?.appDir) {
result.experimental.enableUndici = true
}

if (result.basePath !== '') {
if (result.basePath === '/') {
throw new Error(
Expand Down
3 changes: 3 additions & 0 deletions packages/next/server/next-server.ts
Expand Up @@ -99,6 +99,7 @@ import { IncrementalCache } from './lib/incremental-cache'
import { normalizeAppPath } from '../shared/lib/router/utils/app-paths'

import { renderToHTMLOrFlight as appRenderToHTMLOrFlight } from './app-render'
import { setHttpClientAndAgentOptions } from './config'

export * from './base-server'

Expand Down Expand Up @@ -260,6 +261,8 @@ export default class NextNodeServer extends BaseServer {
const { AsyncLocalStorage } = require('async_hooks')
;(global as any).AsyncLocalStorage = AsyncLocalStorage
}
// ensure options are set when loadConfig isn't called
setHttpClientAndAgentOptions(this.nextConfig)
}

private compression = this.nextConfig.compress
Expand Down