Uh oh!
There was an error while loading. Please reload this page.
fix(sync): wait for initialize before leaving __enter__ - #3168
Open
Skn0tt wants to merge 2 commits into
Open
Conversation
Fixes: microsoft#3165 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 16cb16dc-1986-42c7-90ce-9549b32cfccb
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 16cb16dc-1986-42c7-90ce-9549b32cfccb
dcrousso
requested changes
Aug 4, 2026
| try: | ||
| self.playwright_future.set_result(await self._root_object.initialize()) | ||
| except BaseException as exc: | ||
| self.playwright_future.set_exception(exc) |
There was a problem hiding this comment.
i think the async context manager cancels playwright_future when the transport fails first so this may raise InvalidStateError and replace the original failure in _init_task
| self.playwright_future.set_result(await self._root_object.initialize()) | ||
| except BaseException as exc: | ||
| self.playwright_future.set_exception(exc) | ||
| raise |
There was a problem hiding this comment.
_init_task does not appear to be awaited or inspected so i think rethrowing here will emit Task exception was never retrieved after the caller has already received the startup error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes half of #3165
sync_api/_context_manager.pyblocked until the Playwright__create__, butsince #836 we really have to block until
initializefinishes. Emptywith sync_playwright()was racing teardown against that still-in-flight RPCand printing
Future exception was never retrieved/Task was destroyed but it is pendingon exit.Migrating to wait on
playwright_future(like async) also lets us drop thenow-unused
call_on_object_with_known_namepath.Does not touch the separate JSON-serialization / register-after-send half.