Skip to content

feat: add ignoreOutdatedRequests option to optimizeDeps#21364

Merged
sapphi-red merged 3 commits intovitejs:mainfrom
jamesopstad:ignore-outdated-requests
Jan 7, 2026
Merged

feat: add ignoreOutdatedRequests option to optimizeDeps#21364
sapphi-red merged 3 commits intovitejs:mainfrom
jamesopstad:ignore-outdated-requests

Conversation

@jamesopstad
Copy link
Contributor

Fixes #20867.

This adds an experimental optimizeDeps.ignoreOutdatedRequests option that prevents throwing errors when outdated dependencies are encountered. I haven't added docs as I see this more as a temporary workaround for a specific issue. The longer term fix is to use full-bundle mode rather than optimizeDeps in the Cloudflare plugin.

Note that I haven't applied this change to the following code in the import analysis plugin. Let me know if I should:

if (!importerModule) {
// This request is no longer valid. It could happen for optimized deps
// requests. A full reload is going to request this id again.
// Throwing an outdated error so we properly finish the request with a
// 504 sent to the browser.
throwOutdatedRequest(importer)
}

@jamesopstad jamesopstad changed the title Add ignoreOutdatedRequests option to optimizeDeps fix: add ignoreOutdatedRequests option to optimizeDeps Jan 5, 2026
@jamesopstad jamesopstad changed the title fix: add ignoreOutdatedRequests option to optimizeDeps feat: add ignoreOutdatedRequests option to optimizeDeps Jan 5, 2026
@jamesopstad
Copy link
Contributor Author

If this PR is approved, it would be great if it could be released in Vite 7 and Vite 8. Let me know if there's anything I need to do to enable that.

Comment on lines +53 to +57
if (
browserHash &&
info.browserHash !== browserHash &&
!environment.config.optimizeDeps.ignoreOutdatedRequests
) {
Copy link
Contributor Author

@jamesopstad jamesopstad Jan 5, 2026

Choose a reason for hiding this comment

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

This is where the issue occurs but it seems best to apply the option in each of the places the error is thrown.

@sapphi-red sapphi-red added the p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) label Jan 7, 2026
@sapphi-red sapphi-red merged commit b2e75aa into vitejs:main Jan 7, 2026
19 checks passed
@sapphi-red
Copy link
Member

@jamesopstad I've released this in 7.3.1 & 8.0.0-beta.6 👍

@jamesopstad
Copy link
Contributor Author

@jamesopstad I've released this in 7.3.1 & 8.0.0-beta.6 👍

Thanks a lot @sapphi-red!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimizer behaviour change leading to errors

2 participants