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

Make hard JS indexof not found error more developer-friendly #24744

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

matthargett
Copy link
Contributor

Summary

While debugging some new console output in the debugger complaining about a call attempt on a non-function, I found this test's toThrow() was meant to capture the hard JS error, but wasn't specific. To make the toThrow() more specific, and provide more helpful information in the error, I crafted a more developer-friendly message to include in the thrown Error that should save a debugging cycle for the next people that run into it. I noticed that I had to add the check in removeChild as well, which attempted to call indexOf on the same invalid parentInstance.children without checking the type.

How did you test this change?

I augmented the existing test to verify the specific user-friendly thrown error, and added a second test case that captures the original abuse case whose debugging led me to discover this issue. yarn test and yarn test --prod both pass on my x64 MacBook Pro running MacOS 12.4 and the node version specified in the repo's .nvmrc file.

…dexOf'. Throw a more specific error with a clue about what parentInstance.child actually was when it was called incorrectly. Add the check to removeChild, since that gets called with the same invalid parentInstance even though addChild threw and never completed.
@sizebot
Copy link

sizebot commented Jun 17, 2022

Comparing: 56389e8...7ba1e65

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 131.64 kB 131.64 kB = 42.30 kB 42.30 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 136.92 kB 136.92 kB = 43.89 kB 43.89 kB
facebook-www/ReactDOM-prod.classic.js = 440.83 kB 440.83 kB = 80.64 kB 80.64 kB
facebook-www/ReactDOM-prod.modern.js = 426.13 kB 426.13 kB = 78.45 kB 78.45 kB
facebook-www/ReactDOMForked-prod.classic.js = 441.61 kB 441.61 kB = 80.87 kB 80.87 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable-semver/react-test-renderer/cjs/react-test-renderer.production.min.js +0.32% 89.02 kB 89.31 kB +0.47% 27.54 kB 27.67 kB
oss-stable/react-test-renderer/cjs/react-test-renderer.production.min.js +0.32% 89.05 kB 89.34 kB +0.46% 27.54 kB 27.67 kB
oss-stable-semver/react-test-renderer/umd/react-test-renderer.production.min.js +0.32% 89.31 kB 89.59 kB +0.24% 27.92 kB 27.99 kB
oss-stable/react-test-renderer/umd/react-test-renderer.production.min.js +0.32% 89.33 kB 89.62 kB +0.24% 27.92 kB 27.99 kB
oss-experimental/react-test-renderer/cjs/react-test-renderer.production.min.js +0.31% 93.49 kB 93.77 kB +0.41% 28.89 kB 29.01 kB
oss-experimental/react-test-renderer/umd/react-test-renderer.production.min.js +0.30% 93.76 kB 94.04 kB +0.24% 29.24 kB 29.31 kB

Generated by 🚫 dangerJS against 7ba1e65

@matthargett matthargett marked this pull request as ready for review June 17, 2022 01:09
Copy link

This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.

@github-actions github-actions bot added the Resolution: Stale Automatically closed due to inactivity label Apr 10, 2024
@matthargett
Copy link
Contributor Author

bump

@github-actions github-actions bot removed the Resolution: Stale Automatically closed due to inactivity label Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants