GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — DevTools Suspense cache cleanup by bvaughn · Pull Request #22275 · react/react

Conversation

@bvaughn

@bvaughn bvaughn commented Sep 8, 2021

Copy link
Copy Markdown
Contributor

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.

All reactions
Brian Vaughn added 3 commits September 8, 2021 18:40
Brian Vaughn
Hardened DevTools Suspense caches
0fcde7a
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).
Brian Vaughn
Guard against sourceMappingURL expression in code
c03fdbc
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
Brian Vaughn
Fixed a comment typo 🤡
28d5f06
@bvaughn
bvaughn requested review from jstejada and lunaruan September 8, 2021 22:42
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Sep 8, 2021
jstejada
jstejada approved these changes Sep 8, 2021
View reviewed changes

@jstejada jstejada left a comment

Copy link
Copy Markdown
Contributor

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.

All reactions
lunaruan
lunaruan approved these changes Sep 8, 2021
View reviewed changes
@bvaughn

bvaughn commented Sep 9, 2021

Copy link
Copy Markdown
Contributor Author

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
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bvaughn
bvaughn merged commit 24c2e27 into react:main Sep 9, 2021
@bvaughn
bvaughn deleted the devtools-suspense-cache-hadening branch September 9, 2021 13:28
gaearon
gaearon reviewed Sep 9, 2021
View reviewed changes
Comment thread packages/react-devtools-shared/src/hookNamesCache.js

const thenable = loadHookNamesFunction(hooksTree, fetchFileWithCaching);
thenable.then(onSuccess, onError);
if (typeof (thenable: any).catch === 'function') {

@gaearon gaearon Sep 9, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

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
All reactions
  • 👍 1 reaction

@bvaughn bvaughn Sep 9, 2021

Copy link
Copy Markdown
Contributor Author

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.

All reactions

@bvaughn bvaughn Sep 9, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

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
All reactions
  • 👍 1 reaction

@bvaughn bvaughn Sep 9, 2021

Copy link
Copy Markdown
Contributor Author

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.

Reverted in 3c3f072

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bvaughn bvaughn Sep 9, 2021

Copy link
Copy Markdown
Contributor Author

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.

Bit of follow-up.

After reverting that bit of the change, and using the test shell (with HMR on) for a little bit, I think I see the "uncaught error" issue I initially noticed. Digging in a little more, I think it actually comes from this code which doesn't pass the error handler:

https://github.com/facebook/react/blob/8f96c6b2ac3ff0e38f60c87b1f08deb9993526b5/packages/react-devtools-shared/src/inspectedElementCache.js#L178-L195

So I think this was my mistake. Thanks for questioning this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jstejada and gaearon reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

@jstejada jstejada Sep 9, 2021

Copy link
Copy Markdown
Contributor

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.

All reactions

@gaearon gaearon Sep 9, 2021

Copy link
Copy Markdown
Collaborator

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
All reactions
  • 👍 1 reaction
This was referenced Sep 9, 2021
Add named hooks support to react-devtools-inline #22263
Merged
Revert Suspense cache Thenable.catch() change #22280
Merged
bvaughn pushed a commit that referenced this pull request Sep 9, 2021
Brian Vaughn
Revert Suspense cache Thenable.catch() change (#22280)
96814e7
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
Brian Vaughn @zhengjitf
DevTools Suspense cache cleanup (react#22275)
750b080
zhengjitf pushed a commit to zhengjitf/react that referenced this pull request Apr 15, 2022
Brian Vaughn @zhengjitf
Revert Suspense cache Thenable.catch() change (react#22280)
ef7fd4e
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
Brian Vaughn
DevTools Suspense cache cleanup (react#22275)
09609dc
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
Brian Vaughn
Revert Suspense cache Thenable.catch() change (react#22280)
38a8c8c
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
Brian Vaughn
DevTools Suspense cache cleanup (react#22275)
a4adb8b
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
Brian Vaughn
Revert Suspense cache Thenable.catch() change (react#22280)
835acb2
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gaearon gaearon gaearon left review comments
+2 more reviewers
@jstejada jstejada jstejada approved these changes
@lunaruan lunaruan lunaruan approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

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.

5 participants

@bvaughn @gaearon @jstejada @lunaruan @facebook-github-bot
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.