-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
fix(gatsby): Improve error message when EnsureResources fails to ensure a resource #21429
Conversation
757ece5
to
342b19e
Compare
342b19e
to
96ab5d5
Compare
@@ -12,7 +12,8 @@ | |||
"strictPropertyInitialization": true, | |||
"noFallthroughCasesInSwitch": true, | |||
"resolveJsonModule": true, | |||
"esModuleInterop": true | |||
"esModuleInterop": true, | |||
"jsx": "preserve" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this flag is so we can do react stuff. it was throwing an error and breaking builds
I have reservation about this - this will hide actual error in the runtime so it's more difficult to try to debug things. This is particularly problematic when the service worker is involved (because state of service worker caches etc is not sharable, and actual errors is only thing we can use to try to get to the bottom of things - it's still not easy, and sometimes even impossible to do, but at least there might be some clues). So I don't know if hiding error here is good idea? |
@pieh I may be wrong. But I don't think this is really making any functional difference from what is happening currently besides that the error it reports is more helpful. Currently without our change, we call the Since this code is assuming |
`This typically means that an issue occurred building components for that path` | ||
) | ||
throw new Error( | ||
`EnsureResources was not able to find resources for path: "${this.props.location.pathname}"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not duplicate this line in warning and error message - I would vote to get rid of warn completely and just put this whole text in thrown error - sounds reasonable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I was mostly thinking about production builds here - maybe we should have conditional logic for gatsby develop
(using process.env.NODE_ENV === `production`
to show short(ish) message, but for gatsby develop
case we can show cleaning up .cache
(but it probably should be both .cache
and public
given stale page-data being on of potential reasons for this)
Hmmm, ok - I can agree with that. I'm not sure if we should mention wiping Tho with recent discovery that error like this is caused by stale |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added small comment, after that I think it's good to go
Co-Authored-By: Ward Peeters <[email protected]>
Fixed in |
Description
Documentation
It turns out that in rare cases, EnsureResources can fail. It's not currently known what can cause it. But the outcome of when it fails is that we hit an error accessing properties on an undefined object. https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/cache-dir/root.js#L75
So this fix at least throws an error in render and doesn't try to render the app causing misleading errors.
Related Issues
Addresses #19959