-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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: handle warmup request error correctly #16223
fix: handle warmup request error correctly #16223
Conversation
Run & review this pull request in StackBlitz Codeflow. |
Thanks for the alternative! I'm not sure if we should keep throwing the error though. Maybe it is ok to try first this PR. I'm afraid now about external code calling But I'm fine going with this one if you prefer that. |
Makes sense. But if we are going that way, I think we'll need to remove all of these. vite/packages/vite/src/node/server/middlewares/transform.ts Lines 216 to 269 in d443428
|
I think we could keep the |
Thank you 🙇♂️ Looking forward to trying this out. |
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
).