Skip to content

Commit

Permalink
Add experimental proxy timeout option (#40289)
Browse files Browse the repository at this point in the history
<!--
Thanks for opening a PR! Your contribution is much appreciated.
In order to make sure your PR is handled as smoothly as possible we
request that you follow the checklist sections below.
Choose the right checklist for the change that you're making:
-->

## Bug

- [X] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

Fixes #36251
  • Loading branch information
bcheidemann committed Sep 7, 2022
1 parent abbe3b0 commit fbf1c97
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/next/server/config-schema.ts
Expand Up @@ -320,6 +320,10 @@ const configSchema = {
profiling: {
type: 'boolean',
},
proxyTimeout: {
minimum: 0,
type: 'number',
},
runtime: {
// automatic typing doesn't like enum
enum: ['experimental-edge', 'nodejs'] as any,
Expand Down
2 changes: 2 additions & 0 deletions packages/next/server/config-shared.ts
Expand Up @@ -90,6 +90,7 @@ export interface ExperimentalConfig {
cpus?: number
sharedPool?: boolean
profiling?: boolean
proxyTimeout?: number
isrFlushToDisk?: boolean
workerThreads?: boolean
pageEnv?: boolean
Expand Down Expand Up @@ -550,6 +551,7 @@ export const defaultConfig: NextConfig = {
isrFlushToDisk: true,
workerThreads: false,
pageEnv: false,
proxyTimeout: undefined,
optimizeCss: false,
nextScriptWorkers: false,
scrollRestoration: false,
Expand Down
5 changes: 4 additions & 1 deletion packages/next/server/next-server.ts
Expand Up @@ -697,7 +697,10 @@ export default class NextNodeServer extends BaseServer {
ws: true,
// we limit proxy requests to 30s by default, in development
// we don't time out WebSocket requests to allow proxying
proxyTimeout: upgradeHead && this.renderOpts.dev ? undefined : 30_000,
proxyTimeout:
upgradeHead && this.renderOpts.dev
? undefined
: this.nextConfig.experimental.proxyTimeout || 30_000,
})

await new Promise((proxyResolve, proxyReject) => {
Expand Down

0 comments on commit fbf1c97

Please sign in to comment.