-
Notifications
You must be signed in to change notification settings - Fork 26.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): allow configuration of http-server's timeout configuration (…
…#35827) * feat: add keep-alive timeout params for next-start * feat: add keep-alive timeout args to next-cli's start * docs: add docs for keep-alive timeouts * docs: fix grammar & typos * refactor: handle NaN for args * test: add tests for timeout args * revert: remove headersTimeout option * fix: remove input validation for keepAliveTimeout arg * feat: add input-range validation for keepAliveTimeout arg * Error and tests for range validation * Make sure timeout actually changes * Fix error messsage * Apply suggestions from code review Co-authored-by: Steven <steven@ceriously.com> Co-authored-by: Hannes Bornö <hannes.borno@vercel.com> Co-authored-by: Balázs Orbán <info@balazsorban.com> Co-authored-by: Steven <steven@ceriously.com>
- Loading branch information
1 parent
bcd8de3
commit 2b451ee
Showing
5 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { nextStart } from 'next/dist/cli/next-start' | ||
import httpMock, { Server } from 'http' | ||
|
||
// Prevents bin from running | ||
jest.mock('next/dist/bin/next', () => ({})) | ||
jest.mock('next/dist/lib/get-project-dir', () => ({ getProjectDir: () => '' })) | ||
|
||
jest.mock('http') | ||
|
||
describe('start', () => { | ||
test('--keepAliveTimeout changes server.keepAliveTimeout when passed', () => { | ||
const server = { | ||
on: () => {}, | ||
listen: () => {}, | ||
} as any as Server | ||
;(httpMock as any).createServer.mockReturnValue(server) | ||
|
||
expect(server.keepAliveTimeout).toBe(undefined) | ||
nextStart(['--keepAliveTimeout', '1234']) | ||
expect(server.keepAliveTimeout).toBe(1234) | ||
}) | ||
|
||
test("--keepAliveTimeout doesn't change server.keepAliveTimeout when not passed", () => { | ||
const server = { | ||
on: () => {}, | ||
listen: () => {}, | ||
} as any as Server | ||
;(httpMock as any).createServer.mockReturnValue(server) | ||
|
||
expect(server.keepAliveTimeout).toBe(undefined) | ||
nextStart([]) | ||
expect(server.keepAliveTimeout).toBe(undefined) | ||
}) | ||
}) |