-
-
Notifications
You must be signed in to change notification settings - Fork 331
Bug fix for corrupted hook state #1254
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
Conversation
--------- Co-authored-by: James Hutchison <122519877+JamesHutchison@users.noreply.github.com>
|
@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. |
* Bug fix for corrupted hook state - change hook state to a contextvar --------- Co-authored-by: James Hutchison <122519877+JamesHutchison@users.noreply.github.com>
|
Even if it may not be relevant anymore: The pytest-asyncio issue regarding the propagation of contextvars between fixtures and tests has been resolved as of pytest-asyncio v1.1.0. |
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
ThreadLocalfor the hook stack, we now use aContextVarwhen ReactPy is run with a webserver. However, we still have to use aThreadLocalwhen rendering viapyodidedue to lack ofContextVarsupport.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
ContextVarvalues 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).