fix: handle warmup request error correctly #16223
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Alternative to #16216
From the stack trace, I guess this would catch the error correctly.
The reason why
.catch(e =>
cannot catch the error is becausetransformRequest
throws an error in sync instead of async.vite/packages/vite/src/node/server/transformRequest.ts
Line 58 in d443428
Sync errors can only be catched by
try {} catch {}
.The fix for it would be to change
transformRequest
to an async function (that would change the sync error into async error), or, to usetry { await transformRequest() } catch {}
. Using both.catch
andtry {} catch {}
is also an option.https://stackblitz.com/edit/node-zucmtr?file=index.js
I went with
try { await transformRequest() } catch {}
.Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).