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

Handle chunkLoadError #771

Merged
merged 4 commits into from
Jun 15, 2021
Merged

Handle chunkLoadError #771

merged 4 commits into from
Jun 15, 2021

Conversation

tlgimenes
Copy link
Contributor

@tlgimenes tlgimenes commented Jun 15, 2021

What's the purpose of this pull request?

Fix being redirected to 500 page on a ChunkLoadError.

reload

How it works?

Today, whenever an error happens, we redirect the user to the 500 page. If the user refreshs way too fast or if the file is not available on the server anymore, webpack throws a ChunkLoadError and the user is redirected to the 500 page.

This PR solves this problem by refreshing the page when a ChunkLoadError happens on the React tree.

How to test it?

Refresh like crazy the home page before and after this PR. You will notice that eventually, you will be redirected to the 500 page. After this PR this shouldn't happen

https://github.com/vtex-sites/marinbrasil.store/pull/524
https://github.com/vtex-sites/btglobal.store/pull/626

@netlify
Copy link

netlify bot commented Jun 15, 2021

✔️ Deploy Preview for storeui ready!

🔨 Explore the source changes: 81c08f8

🔍 Inspect the deploy log: https://app.netlify.com/sites/storeui/deploys/60c8ff27dd5722000871574d

😎 Browse the preview: https://deploy-preview-771--storeui.netlify.app

@tlgimenes tlgimenes force-pushed the fix/relax-error-handler branch from de4d43c to 5d3866c Compare June 15, 2021 17:26
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 15, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 81c08f8:

Sandbox Source
Store UI Typescript Configuration

@tlgimenes tlgimenes marked this pull request as ready for review June 15, 2021 19:12
@tlgimenes tlgimenes requested a review from a team as a code owner June 15, 2021 19:12
Copy link
Member

@emersonlaurentino emersonlaurentino left a comment

Choose a reason for hiding this comment

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

it would be nice if we had a flag that checks process.env.NODE_ENV to disable this when in development because this is only useful in production.

Like that:

// ...
  useEffect(() => {
    if (process.env.NODE_ENV === "production") handleError({ error, errorId })
  }, [error, errorId])
// ...

} else if (is404) {
window.location.href = `/404?from=${from}`
} else {
window.location.href = `/500?from=${from}&errorId=${errorId ?? uuidv4()}`
Copy link
Member

Choose a reason for hiding this comment

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

we need to add sentry here, in an agnostic way to the store can configure a own sentry

Copy link
Contributor Author

@tlgimenes tlgimenes Jun 15, 2021

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

yes, but we only generate a random id with uuid when the store does not shadowing this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. AFAIK sentry is open source right?

@tlgimenes
Copy link
Contributor Author

tlgimenes commented Jun 15, 2021

This was like this before, but I removed this if because sometimes we do want to see the error handling in action during development. Also, this ensure the same behavior in dev and in prod

Edit: But yes we can try

@heynemann
Copy link

I tested the preview and it works as expected in my case. Previously it was easy to reproduce. Can't reproduce it anymore in this PR.

@tlgimenes tlgimenes merged commit f450dfc into master Jun 15, 2021
@tlgimenes tlgimenes deleted the fix/relax-error-handler branch June 15, 2021 19:38
bentoper pushed a commit that referenced this pull request Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants