Skip to content

Commit

Permalink
Fix experimental undici warning (vercel#41077)
Browse files Browse the repository at this point in the history
Fixes: https://vercel.slack.com/archives/C03KAR5DCKC/p1664581332858249

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`
  • Loading branch information
ijjk authored and BowlingX committed Oct 5, 2022
1 parent d270727 commit cc06d0b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/next/server/config.ts
Expand Up @@ -49,12 +49,16 @@ const experimentalWarning = execOnce(

export function setHttpClientAndAgentOptions(options: NextConfig) {
if (semverGte(process.version, '16.8.0')) {
if (semverGte(process.version, '18.0.0')) {
if (
options.experimental?.enableUndici &&
semverGte(process.version, '18.0.0')
) {
Log.warn(
'`enableUndici` option is unnecessary in Node.js v18.0.0 or greater.'
)
} else {
;(global as any).__NEXT_USE_UNDICI = options.experimental?.enableUndici
}
;(global as any).__NEXT_USE_UNDICI = options.experimental?.enableUndici
} else if (options.experimental?.enableUndici) {
Log.warn(
'`enableUndici` option requires Node.js v16.8.0 or greater. Falling back to `node-fetch`'
Expand Down
5 changes: 5 additions & 0 deletions test/e2e/prerender.test.ts
Expand Up @@ -2428,6 +2428,11 @@ describe('Prerender', () => {
expect(next.cliOutput).not.toContain('Failed to update prerender cache')
})

it('should not have experimental undici warning', async () => {
await waitFor(1000)
expect(next.cliOutput).not.toContain('option is unnecessary in Node.js')
})

it('should not have attempted sending invalid payload', async () => {
expect(next.cliOutput).not.toContain('argument entity must be string')
})
Expand Down

0 comments on commit cc06d0b

Please sign in to comment.