GeezerVison is showing github.com — DevTools Suspense cache cleanup by bvaughn · Pull Request #22275 · react/react
Conversation
Fixed a few things I noticed while testing #22263.
Commits can be reviewed independently.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Use .catch() to handle errors in a chained promise. Previously certain errors would slip through without being caught, eventually resulting in the Suspense cache timeout (but not logging the underlying error).
I thought I had sufficiently guarded against this previously, but when testing the react-devtools-inline package with Webpack, I found another case that caused the hook names code to throw. I added a failing test mimicking this case, and then fixed the problem in loadSourceAndMetadata
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.
thanks! i've noticed that sometimes parsing hook names can fail silently, or just without any indication of failure in the UI or logs.. would this change address that issue?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
thanks! i've noticed that sometimes parsing hook names can fail silently, or just without any indication of failure in the UI or logs.. would this change address that issue?
Yes, that's the goal. Should at least log an error now (to the nested devtools console)
|
jstejada reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
|
|
|
const thenable = loadHookNamesFunction(hooksTree, fetchFileWithCaching);
|
|
|
thenable.then(onSuccess, onError);
|
|
|
if (typeof (thenable: any).catch === 'function') {
|
gaearon
Sep 9, 2021
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
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 does not look right to me. Can you elaborate on the reasoning for why this makes sense?
Normally, catch is not a part of the Thenable contract altogether. In Promises, .catch(onError) is a convenience that translates to .then(undefined, onError). So from what I see in this implementation, if thenable is a Promise, the consequence should be that onError runs twice:
thenable.then(onSuccess, onError)
thenable.then(undefined, onError)
I don't think this is what was intended.
Do you have a specific example case that you're trying to fix here? I suspect there's some other problem that was covered up, and maybe this accidentally fixes it, but it seems like a wrong fix.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
jstejada reacted with thumbs up emoji
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.
As I understand it, catch should really only be necessary if an error was thrown inside of onSuccess or onError – but what I noticed yesterday when testing a source-map parsing problem (inside of the hooks/parseHookNames module) was that the onError callback wasn't being invoked, and the error was effectively being swallowed (until the timeout eventually fired).
I can try to repro this by backing out this change, if that would be helpful.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
bvaughn
Sep 9, 2021
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
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.
I checked out bvaughn:devtools-dynamic-import-suspense-cache (#22263), and partially reverted this commit (24c2e27), and tried to repro the problem I saw yesterday and I'm not able. Kind of a head scratcher, but it tracks with my understanding of how .catch() works.
I can revert this specific change from this PR and leave the rest. Maybe @jstejada can weigh in if he sees another case where we aren't handling an error correctly in the cache?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
jstejada reacted with thumbs up emoji
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
jstejada and gaearon reacted with thumbs up emoji
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.
not sure if related, but yes i am planning to look into a case where we seemed to not handle an error, will report back as to whether it's related to this or not
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
As I understand it, catch should really only be necessary if an error was thrown inside of onSuccess or onError
So I think it’s okay (and intentional) not to catch errors in these, just like React doesn’t. Because they should have the minimal logic that sets the values in the cache and have no reason to throw. If they do throw then that’s a bug in the cache, which should be surfaced as unhandled.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
jstejada reacted with thumbs up emoji
This was referenced Sep 9, 2021
bvaughn
pushed a commit
that referenced
this pull request
Sep 9, 2021
Reverts part of #22275 (adding .catch() to Thenables in Suspense caches) in response to #22275 (comment).
After taking another look with fresh eyes, I think I see the "uncaught error" issue I initially noticed was in checkForUpdate() (which did not pass an error handler to .then)
zhengjitf
pushed a commit
to zhengjitf/react
that referenced
this pull request
Apr 15, 2022
Reverts part of react#22275 (adding .catch() to Thenables in Suspense caches) in response to react#22275 (comment).
After taking another look with fresh eyes, I think I see the "uncaught error" issue I initially noticed was in checkForUpdate() (which did not pass an error handler to .then)
mrizwanashiq
pushed a commit
to mrizwanashiq/react
that referenced
this pull request
Jun 25, 2026
Reverts part of react#22275 (adding .catch() to Thenables in Suspense caches) in response to react#22275 (comment).
After taking another look with fresh eyes, I think I see the "uncaught error" issue I initially noticed was in checkForUpdate() (which did not pass an error handler to .then)
hanzo-dev
pushed a commit
to hanzoai/react
that referenced
this pull request
Sep 9, 2026
Reverts part of react#22275 (adding .catch() to Thenables in Suspense caches) in response to react#22275 (comment).
After taking another look with fresh eyes, I think I see the "uncaught error" issue I initially noticed was in checkForUpdate() (which did not pass an error handler to .then)
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|