test(code): sandbox creation must not run on the blockbuster-guarded loop - #6017
Open
Jack Michaud (jack-michaud) wants to merge 2 commits into
Open
test(code): sandbox creation must not run on the blockbuster-guarded loop#6017Jack Michaud (jack-michaud) wants to merge 2 commits into
Jack Michaud (jack-michaud) wants to merge 2 commits into
Conversation
…loop Reproduces the `dcode --sandbox <provider>` startup failure: the langgraph dev server arms the blockbuster blocking-I/O guard on the event loop, and _make_graphs calls the sync provider get_or_create directly on it, so the readiness check dies with "Blocking call to socket.socket.connect". Fails on main; passes once sandbox creation is offloaded off the event loop (e.g. asyncio.to_thread).
Contributor
|
This PR has been automatically closed because you are not assigned to the linked issue. Opening a PR is not an indication that it will be accepted. This process exists so maintainers can confirm a change is aligned with the project direction before you invest time implementing it. Please:
Maintainers: reopen this PR or remove the |
Matches the existing test_interpreter_settings_apply_before_agent_construction pattern: with no_mcp=True and the stubbed tools module, _build_tools does no blocking I/O, so it can run on the loop under the blockbuster guard.
This was referenced Sep 2, 2026
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 free
to 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.
Summary
Failing regression test for a server-startup bug: sandbox creation runs synchronously on the LangGraph dev event loop and is killed by the blockbuster blocking-I/O guard.
Failure:
dcode --sandbox <provider>(reproduced on langsmith, agentcore, and previously reported for daytona in #5278) aborts before the readiness check passes:Root cause:
langgraph devarms blockbuster (langgraph_runtime_inmem/queue.py->_enable_blockbuster()), which raisesBlockingErrorfor patched blocking calls (socket connect,time.sleep, ...) on the asyncio loop._make_graphsis async and calls the synccreate_sandbox(...)/__enter__()directly on that loop (server_graph.py), which invokes the provider's syncget_or_create(...)— real blocking I/O. Every other blockbuster-hostile step in_make_graphsis already offloaded viaasyncio.to_thread(with comments citing #5043); sandbox creation is the one that was missed. NoteSandboxProvider.aget_or_createexists but has zero call sites.What this test does
Mimics the server's guard with
BlockBuster().activate()around a real_make_graphsrun (modules stubbed per the existingtest_interpreter_settings_apply_before_agent_constructionpattern). The fake provider's syncget_or_createdoes atime.sleep— deterministic, and safe under pytest-socket's--disable-socket, unlike a real socket connect. Onmain, blockbuster raisesBlockingError,_make_graphshits its startup-error path, and the test fails withSystemExit(1). Once sandbox creation is offloaded off the event loop (e.g.asyncio.to_thread, matching the existing pattern in this file), the provider runs in a worker thread and the test passes. Verified locally: fails on main, passes with the to_thread fix applied.Implementation notes
BlockBuster().activate()/deactivate()rather thanblockbuster_ctx: blockbuster <1.5.27 lacks thetry/finallyin that helper, so the guard leaks into later tests when the body raises. The repo's uv.lock currently pins 1.5.26. The explicit form is version-stable and always restores.test_server_graph.py(the server-side seam where the fix belongs), reusing the existing_import_fresh_server_graph/_backend_with_offloadhelpers.Out of scope
Deliberately a test-only PR (per the bug template guidance). The fix itself is straightforward — offload sandbox creation off the event loop — and will be tracked by the follow-up issue referencing this PR.
Fixes #6018