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

fix(core): log missing errorInfo in React 18 onRecoverableError callback #9387

Merged
merged 2 commits into from
Oct 9, 2023

Conversation

johnnyreilly
Copy link
Contributor

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

See #9379

Test Plan

I hope to use this to diagose #9379

Test links

Related issues/PRs

See #9379

@netlify
Copy link

netlify bot commented Oct 9, 2023

[V2]

Name Link
🔨 Latest commit 16dd756
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/6523fd222b99aa0008f77555
😎 Deploy Preview https://deploy-preview-9387--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions
Copy link

github-actions bot commented Oct 9, 2023

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 81 🟢 97 🟢 92 🟢 100 🟠 89 Report
/docs/installation 🟠 86 🟢 98 🟢 92 🟢 100 🟠 89 Report

Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

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

looks like lint/prettier fails

@@ -37,8 +37,8 @@ if (ExecutionEnvironment.canUseDOM) {
</HelmetProvider>
);

const onRecoverableError = (error: unknown): void => {
console.error('Docusaurus React Root onRecoverableError:', error);
const onRecoverableError = (error: unknown, errorInfo: { digest?: string | null, componentStack?: string | null }): void => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks, missed that we could get some additional info in the callback

Why not using the official type ReactDOM.ErrorInfo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the official type ReactDOM.ErrorInfo

Oh. where is that type found? I used the implementation I found in the React codebase - do you have another link?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, will try to fix it

Copy link
Collaborator

Choose a reason for hiding this comment

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

probably only exists on external typedefs, fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh so the type you're using is from DefinitelyTyped: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/29f3f65685aba9e9b8a105a55494923980e2f16e/types/react/index.d.ts#L3240

Ironically, I'm one of the maintainers of that. It's slightly inaccurate too :-). But it doesn't really matter - we just want the console.log to take place

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've raised a PR to update the Definitely Typed definition to be more accurate: DefinitelyTyped/DefinitelyTyped#66987

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes I know that's why I didn't understand 😅 great if you catched a typo

@slorber slorber added the pr: bug fix This PR fixes a bug in a past release. label Oct 9, 2023
@slorber slorber changed the title feat: log errorInfo from onRecoverableError fix(core): log missing errorInfo in React 18 onRecoverableError callback Oct 9, 2023
@slorber slorber merged commit 643a7fe into facebook:main Oct 9, 2023
30 of 31 checks passed
@johnnyreilly johnnyreilly deleted the patch-1 branch October 9, 2023 13:37
@johnnyreilly
Copy link
Contributor Author

See facebook/react#26224

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants