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

Bug fix for corrupted hook state #1254

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

Archmonger
Copy link
Contributor

@Archmonger Archmonger commented Jan 22, 2025

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")

Note to self, consider replacing _ThreadSafeQueue with janus in this PR.

Remaining TODOS

Checklist

Please update this checklist as you complete each item:

  • Tests have been developed for bug fixes or new functionality.
  • The changelog has been updated, if necessary.
  • Documentation has been updated, if necessary.
  • GitHub Issues closed by this PR have been linked.

By submitting this pull request I agree that all contributions comply with this project's open source license(s).

@Archmonger
Copy link
Contributor Author

Archmonger commented Jan 22, 2025

@JamesHutchison I split your ContextVar changes into this PR but it doesn't appear to work within the test suite. Running the test suite results in the following error: LookupError: <ContextVar name='_hook_state' at 0x000001AC3906CF90>

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?

@JamesHutchison
Copy link
Contributor

JamesHutchison commented Jan 27, 2025

The issue is likely that the tests are missing a call to create_hook_state that occurs normally during the rendering loop. I did not run the reactpy tests against my code in the marathon coding week that I wrote most of this. You could probably just add an automatic test fixture.

I do not test reactpy code automatically so this doesn't show up in Heavy Resume.

@Archmonger Archmonger changed the base branch from main to develop January 31, 2025 23:27
@Archmonger Archmonger added the flag-help-wanted Requires presently unavailable expertise or resources. label Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flag-help-wanted Requires presently unavailable expertise or resources.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants