-
Notifications
You must be signed in to change notification settings - Fork 49.2k
Include callstack of act()
call in act()
related warnings
#34112
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
base: main
Are you sure you want to change the base?
Include callstack of act()
call in act()
related warnings
#34112
Conversation
Comparing: 7deda94...60b9844 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
|
0ac6061
to
94779fa
Compare
94779fa
to
60b9844
Compare
Ideally, we shouldn't create Error objects with stack traces for regular errors. We never do that anywhere else because we shouldn't need to. In most scenarios it shouldn't be necessary at all because for example async stacks should work. I think unfortunately because the root of the stack is sync the regular zero-cost stacks don't work. The full async stacks attached by the debugger would work though. Worst case scenario it should use We can set the current owner on the isomorphic React that act is called on with a fake owner named "act()" whose JSX stack trace is the callsite of the act. Owners are basically our user space async stacks. That way This would solve this issue more generally for all errors inside the act and not just these three. I've had many issues with finding which line in a test was running when I get |
I think if we used native async functions inside the act for our scheduling then this would also just work with the zero-cost stacks at least when it's awaited outside. The case when it wouldn't would be if you didn't await the act but if you did, by wouldn't that warn synchronously so you get the stack anyway? |
We're asking test frameworks to implement leverage
The main errors we're targetting here are the ones where the |
I only filed this because I needed it for our tests. And I know I patched this in the past on other codebases. Others would probably find it useful as well when they start pulling in |
Summary
This includes the callsite of the
act
call for the following warnings:A component suspended inside an
actscope, but the
actcall was not awaited. [...]
You seem to have overlapping act() calls [...]
You called act(async () => ...) without await.
All of these warnings require action at the callsite of the
act
so a stack is important to quickly identify where you need to adjust code.Before (no clue where the issue is):
After (the clue is in the stacktrace):
Test frameworks should implement ignore-listing in error inspection to clean up these stacktraces e.g. like Next.js does
How these warnings look in our internal test suite now
It's quite noisy but better than having no stacks. We can look into sourcemapping these stacks and apply ignore-lists if this becomes an issue.
How did you test this change?