Skip to content
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

feat: emit event to handle chunk load errors #12084

Merged
merged 4 commits into from Jun 15, 2023

Conversation

danielroe
Copy link
Contributor

Description

resolves #12080

This PR emits a vite:preloadError event which can be handled by a framework or user. Primarily this will be useful for saving state and reloading an app in the event of a fresh deployment.

Additional context

If preventDefault() is called on this event, the error will not be thrown. I confess I'm not entirely sure whether this is a good idea, but it provides an escape hatch that may be useful.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the PR Title Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@danielroe danielroe changed the title feat(vite): emit event to handle chunk load errors feat: emit event to handle chunk load errors Feb 16, 2023
patak-dev
patak-dev previously approved these changes May 24, 2023
Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

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

It seems we missed this one. I'll add it for discussion in the next team meeting so we can include it in Vite 4.4

@patak-dev patak-dev added the p2-nice-to-have Not breaking anything but nice to have (priority) label May 24, 2023
@KaelWD
Copy link
Contributor

KaelWD commented Jun 13, 2023

When is the next team meeting?

@patak-dev
Copy link
Member

patak-dev commented Jun 13, 2023

@KaelWD in two days. We'll see to resolve the PR async if we don't manage to get to this PR in the meeting. I'll add it to the 4.4 milestone.

@patak-dev patak-dev added this to the 4.4 milestone Jun 13, 2023
@patak-dev patak-dev added p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) and removed p2-nice-to-have Not breaking anything but nice to have (priority) labels Jun 13, 2023
Comment on lines +142 to +144
if (!e.defaultPrevented) {
throw err
}
Copy link
Member

Choose a reason for hiding this comment

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

You need to call preventDefault() on the event. Please avoid commenting on old PRs. You can create a Discussion instead for these questions (linking to a PR if you'd like)

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
Archived in project
Development

Successfully merging this pull request may close these issues.

emit an event when there are errors loading/preloading chunks
3 participants