-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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(preload): allow ignoring dep errors #18046
fix(preload): allow ignoring dep errors #18046
Conversation
Run & review this pull request in StackBlitz Codeflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks for the issue and PR @danielroe!
We can merge this and later backport it so we release it in v5 too. It seems ok for a patch to me.
@@ -93,7 +94,7 @@ function preload( | |||
// in that case fallback to getAttribute | |||
const cspNonce = cspNonceMeta?.nonce || cspNonceMeta?.getAttribute('nonce') | |||
|
|||
promise = Promise.all( | |||
promise = Promise.allSettled( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed that Promise.allSettled
is also supported by our default modern browser target.
https://caniuse.com/mdn-javascript_builtins_promise_allsettled
Co-authored-by: Daniel Roe <[email protected]>
@danielroe [email protected] has been released backporting this PR |
@patak-dev @danielroe I think this broke dynamic preload error handling: https://vitejs.dev/guide/build.html#load-error-handling Since Vite 5.4.4, I am no longer receiving the My preload testing is done as follows:
Environment is Solidjs with the Solid Router, but I don't think this matters much here. This never fires:
John |
@patak-dev @danielroe I've confirmed this. This took a long time to track down. In Vite 5.4.3, the type error still occurs, but there is no 'uncaught in Promise' and the Vite event is produced as expected: John |
That is strange. The code looks correct. @johndunderhill, would you create an issue with a minimal reproduction so we can track and fix this regression? |
Yes, I see the behaviour change. Basically errors called when calling |
Thanks for the report @johndunderhill, and thanks for quickly fixing this @danielroe |
Description
resolves #18042
This allows individual failures of dep preloads without a chain reaction (which Promise.all forces). By default the behaviour is the same, but if frameworks or users call
e.preventDefault
on the chunk errors it is still possible for the preload/import to succeed, which is I think valid in the case of CSS failures.