Skip to content

feat: emit event to handle chunk load errors#12084

Merged
patak-cat merged 4 commits intovitejs:mainfrom
danielroe:feat/preload-err-event
Jun 15, 2023
Merged

feat: emit event to handle chunk load errors#12084
patak-cat merged 4 commits intovitejs:mainfrom
danielroe:feat/preload-err-event

Conversation

@danielroe
Copy link
Copy Markdown
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-cat
patak-cat previously approved these changes May 24, 2023
Copy link
Copy Markdown
Member

@patak-cat patak-cat 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-cat patak-cat added the p2-nice-to-have Not breaking anything but nice to have (priority) label May 24, 2023
@KaelWD
Copy link
Copy Markdown
Contributor

KaelWD commented Jun 13, 2023

When is the next team meeting?

@patak-cat
Copy link
Copy Markdown
Member

patak-cat 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-cat patak-cat added this to the 4.4 milestone Jun 13, 2023
@patak-cat patak-cat 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
Copy Markdown
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