-
-
Notifications
You must be signed in to change notification settings - Fork 323
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
Bug fix for corrupted hook state #1254
Bug fix for corrupted hook state #1254
Conversation
--------- Co-authored-by: James Hutchison <[email protected]>
@JamesHutchison I split your These changes do seem to work fine outside the test runner though - Are there any other changes I'm supposed to migrate from #1204 to get this working? |
The issue is likely that the tests are missing a call to I do not test reactpy code automatically so this doesn't show up in Heavy Resume. |
Description
Due to some backends re-using threads across multiple requests, the hook stack could potentially become corrupted resulting in the following error:
RuntimeError("Hook stack is in an invalid state")
Instead of using a
ThreadLocal
for the hook stack, we now use aContextVar
when ReactPy is run with a webserver. We have to use aThreadLocal
when rendering viapyodide
due to lack ofContextVar
support.This PR was originally based on the work of #1204 but has deviated significantly.
As a note, this PR had to create a new pytest fixture to initialize ReactPy's hook stack. This is typically done automatically within our rendering engine, but unfortunately
ContextVar
values are not retained when using pytest-asyncio async fixtures.Checklist
Please update this checklist as you complete each item:
By submitting this pull request I agree that all contributions comply with this project's open source license(s).