-
Notifications
You must be signed in to change notification settings - Fork 47.6k
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
refactor[ReactDebugHooks]: support parsing stack frames when sourcemaps are available #27612
refactor[ReactDebugHooks]: support parsing stack frames when sourcemaps are available #27612
Conversation
Comparing: 0c63487...a43f175 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
8a5c48a
to
52aa81f
Compare
… files via glob (#27627) This script is used on CI in `yarn_lint` job. With current `glob` call settings, it includes a bunch of build files, which are actually ignored by listing them in `.prettierignore`. This check is not failing only because there is no build step before it. If you run `node ./scripts/prettier/index` with build files present, you will see a bunch of files listed as non-formatted. These changes add a simple logic to include all paths listed in `.prettierignore` to ignore list of `glob` call with transforming them from gitignore-style to glob-style. This should unblock CI for #27612, where `flow-typed` directory will be added, turned out that including it in `.prettierignore` is not enough.
2a401da
to
666a6bc
Compare
666a6bc
to
a43f175
Compare
@hoxyq and I discussed this offline. I think we should unblock #26446 differently. The source mapping behaviour that breaks the existing logic only happens in the test environment, which suggests that #26446 creates divergence between the test and deployed environments of React DevTools. Ergo, AFAICT, we don't have the right kind of test coverage to validate this change, and should instead be looking at ways to keep the tests from breaking post-#26446 without changing any DevTools logic (e.g. by disabling source map generation for |
We should continue to manually exclude For now lets merge your sourcemaps PR with manually excluding sourcemaps, which I will remove later when move |
… files via glob (facebook#27627) This script is used on CI in `yarn_lint` job. With current `glob` call settings, it includes a bunch of build files, which are actually ignored by listing them in `.prettierignore`. This check is not failing only because there is no build step before it. If you run `node ./scripts/prettier/index` with build files present, you will see a bunch of files listed as non-formatted. These changes add a simple logic to include all paths listed in `.prettierignore` to ignore list of `glob` call with transforming them from gitignore-style to glob-style. This should unblock CI for facebook#27612, where `flow-typed` directory will be added, turned out that including it in `.prettierignore` is not enough.
Unblocks #26446.
TL;DR:
isReactWrapper
function implementation. Previously, we would just look at hook stack trace entry and check iffunctionName
ends with the corresponding hook primitive name. This doesn't work with the same setup, but with sourcemaps also being present. We use Proxy for handling custom errors, here is the implementation of the Proxy for Dispatcherreact/packages/react-debug-tools/src/ReactDebugHooks.js
Lines 354 to 373 in 666a6bc
For each supported hook, we have a stub, which saves the stack trace via
new Error()
call. Here isuseState
, for example:react/packages/react-debug-tools/src/ReactDebugHooks.js
Line 142 in 666a6bc
At runtime, current dispatcher can be this Proxy object -
DispatcherProxy
, this will modify the stack trace. Here is how the corresponding stack frame looks like without sourcemaps:When sourcemaps are present, this particular frame is different, it no longer mentions primitive hook name.
We do this parsing to skip React's frames, in this implementation we are only looking for user-defined hooks. In order to make this logic sourcemaps independent, instead of looking at stack trace of the error, which is created at runtime (basically once hook is called), we are also looking at primitive hook's stacktraces, which are defined here:
react/packages/react-debug-tools/src/ReactDebugHooks.js
Lines 57 to 99 in 666a6bc
Notice that we are using general Dispatcher here and not DispatcherProxy. Both with or without sourcemaps stack traces contain corresponding primitive hook name in the
functionName
.Also in these changes:
error-stack-parser
viaflow-typed
, updated other parts of the code which were using this library accordingly.