From cc06d0bc57717db2025846ec7da6025f0c9c74eb Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Fri, 30 Sep 2022 17:20:20 -0700 Subject: [PATCH] Fix experimental undici warning (#41077) 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` --- packages/next/server/config.ts | 8 ++++++-- test/e2e/prerender.test.ts | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/next/server/config.ts b/packages/next/server/config.ts index d5b0899e8f4db..f564f7cd7a144 100644 --- a/packages/next/server/config.ts +++ b/packages/next/server/config.ts @@ -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`' diff --git a/test/e2e/prerender.test.ts b/test/e2e/prerender.test.ts index 7bf0023ef5154..f5e511c444c60 100644 --- a/test/e2e/prerender.test.ts +++ b/test/e2e/prerender.test.ts @@ -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') })