fix(preload): allow ignoring dep errors#18046
Conversation
|
|
patak-cat
left a comment
There was a problem hiding this comment.
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.
| const cspNonce = cspNonceMeta?.nonce || cspNonceMeta?.getAttribute('nonce') | ||
|
|
||
| promise = Promise.all( | ||
| promise = Promise.allSettled( |
There was a problem hiding this comment.
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 <daniel@roe.dev>
|
@danielroe vite@5.4.4 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.preventDefaulton the chunk errors it is still possible for the preload/import to succeed, which is I think valid in the case of CSS failures.