Skip to content

transport_flow session_typescript: a TypeScript method's progress notices can arrive out of order #2082

Closed

Description

@yyhhyyyyyy

session_typescript::node_session_typescript_tools_methods_and_generation_lifetimes failed in CI on 2026-11-23 in the job "Verify public Node bindings" of run https://github.com/arcships/dim/actions/runs/45092266019 (head a4b7ec4):

crates/dim-app-server/tests/transport_flow/session_typescript.rs:1595:5
assertion `left == right` failed
  left: String("settled")
 right: "started"

The test sends session.typescript.status and reads the next frame, expecting the call's first management.progress notice to carry {phase: "started"}. The typescript fixture (runtime/fixtures/session-part.ts:230,233) sends started, then settled, then returns.

Each progress(...) is a call of a callback the host exported to the runtime. The runtime calls it asynchronously (rutis-runtime 0.23.0 src/session.mjs:657-664, #requestAsync at :797-805), so the two sends are two call frames. rutis-bridge 0.23.0 dispatches each incoming call frame on its own task (src/session/rpc.rs:3459-3466), on the multi-threaded runtime that created the callback (src/session/rpc.rs:208-215 and :429-435), so the two tasks can run in either order. Progress::send (crates/dim-agent-capabilities/src/methods.rs:555-559) forwards to the calling connection's FIFO queue (crates/dim-app-server/src/outbound.rs:95-99), which preserves only the order in which the sends happen, and Progress::close (crates/dim-agent-capabilities/src/methods.rs:562-564) drops a send that has not run when the reply is handed over. settled can therefore be delivered first, or started can be dropped.

The behavior arrived with 2a75f95 (#1941, merged 2026-11-20), which moved the pinned runtime from rutis 0.19.3 to 0.23.0. In 0.19.3 an imported callback called outside a synchronous call was served by #requestSync (rutis-runtime 0.19.3 src/session.mjs:464); 0.23.0 serves it through #requestAsync, so an unawaited progress(...) is a separate dispatched frame. ADR 025 D4 (docs/adr/025-rutis-0-23.md:57) states the rule this breaks: "A callback handed over by another plugin or the host is awaited outside a synchronous call."

The upgrade left three places treating progress(...) as a synchronous void call:

  • npm/plugin.d.ts:568 declares MethodProgress as returning void.
  • docs/typescript-plugin-authoring.md:584 shows progress({ phase: 'started' }) without await.
  • runtime/fixtures/session-part.ts:230,233 sends both phases without await.

How to correct the public type and the guide is a separate product-side decision. The fix PR for this issue only awaits the two calls in the test fixture; it leaves the assertion, the public type, the guide and the other fixtures unchanged.

Reproduction with DIM_TEST_NODE, DIM_TEST_JS_RUNTIME and DIM_TEST_RUTIS_SDK set:

cargo test -p dim-app-server --test transport_flow --locked session_typescript::node_session_typescript_tools_methods_and_generation_lifetimes -- --ignored --exact --nocapture

100 isolated runs on head a4b7ec4: 95 passed, 5 failed. 100 isolated runs on main 2d2912b: 96 passed, 4 failed. Every failure is the same assertion at :1595 with settled and started. The test, the fixture and the bridge path are identical on both commits.

No known-failures.tsv entry and no open issue or pull request cover this test.

Possible fixes:

  • Await each progress call in the fixture before sending the next one, so started has reached the host before settled is sent and before the reply closes the channel.
  • Assert that both phases arrive before the reply instead of requiring the first notice to be started.
  • Order callback calls of one reference in rutis-bridge, or keep a call's progress sends ordered and drop only what the connection's allowance cannot take.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions