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

Fix server be killed by handling unhandled promise with status 500 #32080

Closed

Conversation

chentsulin
Copy link
Contributor

@chentsulin chentsulin commented Dec 3, 2021

Fixes #32075.
Catching the whole request handling block seems reasonable to me. The server should not exit the process just because one request error happens.

Bug

  • Related issues linked using fixes #number

@ijjk
Copy link
Member

ijjk commented Dec 3, 2021

Stats from current PR

Default Build (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary chentsulin/next.js fix-UnhandledPromiseRejection Change
buildDuration 24.4s 24s -344ms
buildDurationCached 4.5s 4.4s -167ms
nodeModulesSize 347 MB 347 MB ⚠️ +627 B
Page Load Tests Overall increase ✓
vercel/next.js canary chentsulin/next.js fix-UnhandledPromiseRejection Change
/ failed reqs 0 0
/ total time (seconds) 4.078 4.081 0
/ avg req/sec 613.05 612.64 ⚠️ -0.41
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 2.166 2.078 -0.09
/error-in-render avg req/sec 1154.37 1202.98 +48.61
Client Bundles (main, webpack, commons)
vercel/next.js canary chentsulin/next.js fix-UnhandledPromiseRejection Change
450.HASH.js gzip 179 B 179 B
framework-HASH.js gzip 42.2 kB 42.2 kB
main-HASH.js gzip 28.4 kB 28.4 kB
webpack-HASH.js gzip 1.45 kB 1.45 kB
Overall change 72.3 kB 72.3 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary chentsulin/next.js fix-UnhandledPromiseRejection Change
polyfills-HASH.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary chentsulin/next.js fix-UnhandledPromiseRejection Change
_app-HASH.js gzip 1.37 kB 1.37 kB
_error-HASH.js gzip 194 B 194 B
amp-HASH.js gzip 312 B 312 B
css-HASH.js gzip 326 B 326 B
dynamic-HASH.js gzip 2.38 kB 2.38 kB
head-HASH.js gzip 350 B 350 B
hooks-HASH.js gzip 635 B 635 B
image-HASH.js gzip 4.49 kB 4.49 kB
index-HASH.js gzip 263 B 263 B
link-HASH.js gzip 1.87 kB 1.87 kB
routerDirect..HASH.js gzip 321 B 321 B
script-HASH.js gzip 383 B 383 B
withRouter-HASH.js gzip 318 B 318 B
85e02e95b279..7e3.css gzip 107 B 107 B
Overall change 13.3 kB 13.3 kB
Client Build Manifests
vercel/next.js canary chentsulin/next.js fix-UnhandledPromiseRejection Change
_buildManifest.js gzip 460 B 460 B
Overall change 460 B 460 B
Rendered Page Sizes
vercel/next.js canary chentsulin/next.js fix-UnhandledPromiseRejection Change
index.html gzip 533 B 533 B
link.html gzip 546 B 546 B
withRouter.html gzip 527 B 527 B
Overall change 1.61 kB 1.61 kB

Default Build with SWC
General Overall increase ⚠️
vercel/next.js canary chentsulin/next.js fix-UnhandledPromiseRejection Change
buildDuration 27.4s 26.4s -1s
buildDurationCached 4.5s 4.4s -96ms
nodeModulesSize 347 MB 347 MB ⚠️ +627 B
Page Load Tests Overall increase ✓
vercel/next.js canary chentsulin/next.js fix-UnhandledPromiseRejection Change
/ failed reqs 0 0
/ total time (seconds) 4.146 4.056 -0.09
/ avg req/sec 603.02 616.36 +13.34
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 2.175 2.192 ⚠️ +0.02
/error-in-render avg req/sec 1149.51 1140.64 ⚠️ -8.87
Client Bundles (main, webpack, commons)
vercel/next.js canary chentsulin/next.js fix-UnhandledPromiseRejection Change
450.HASH.js gzip 179 B 179 B
framework-HASH.js gzip 42.3 kB 42.3 kB
main-HASH.js gzip 28.6 kB 28.6 kB
webpack-HASH.js gzip 1.44 kB 1.44 kB
Overall change 72.5 kB 72.5 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary chentsulin/next.js fix-UnhandledPromiseRejection Change
polyfills-HASH.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary chentsulin/next.js fix-UnhandledPromiseRejection Change
_app-HASH.js gzip 1.35 kB 1.35 kB
_error-HASH.js gzip 180 B 180 B
amp-HASH.js gzip 305 B 305 B
css-HASH.js gzip 321 B 321 B
dynamic-HASH.js gzip 2.37 kB 2.37 kB
head-HASH.js gzip 342 B 342 B
hooks-HASH.js gzip 622 B 622 B
image-HASH.js gzip 4.53 kB 4.53 kB
index-HASH.js gzip 256 B 256 B
link-HASH.js gzip 1.9 kB 1.9 kB
routerDirect..HASH.js gzip 314 B 314 B
script-HASH.js gzip 375 B 375 B
withRouter-HASH.js gzip 309 B 309 B
85e02e95b279..7e3.css gzip 107 B 107 B
Overall change 13.3 kB 13.3 kB
Client Build Manifests
vercel/next.js canary chentsulin/next.js fix-UnhandledPromiseRejection Change
_buildManifest.js gzip 458 B 458 B
Overall change 458 B 458 B
Rendered Page Sizes
vercel/next.js canary chentsulin/next.js fix-UnhandledPromiseRejection Change
index.html gzip 533 B 533 B
link.html gzip 546 B 546 B
withRouter.html gzip 528 B 528 B
Overall change 1.61 kB 1.61 kB
Commit: 9880233

Copy link
Member

@ijjk ijjk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I opened an alternative PR for this here which includes responding with a 400 (bad request) for this case and adds some tests, thanks for the PR though!

@chentsulin chentsulin closed this Dec 3, 2021
@chentsulin chentsulin deleted the fix-UnhandledPromiseRejection branch December 3, 2021 17:10
kodiakhq bot pushed a commit that referenced this pull request Dec 3, 2021
This ensures we catch any errors in `handleRequest` so that we can respond with a 400 for invalid requests. 

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/32075
Closes: #32080
@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
natew pushed a commit to natew/next.js that referenced this pull request Feb 16, 2022
This ensures we catch any errors in `handleRequest` so that we can respond with a 400 for invalid requests. 

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/32075
Closes: vercel#32080
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants