File
Blob: src/workerd/api/tests/jsrpc-timing-test.wd-test
| 1 | using Workerd = import "/workerd/workerd.capnp"; |
| 2 | |
| 3 | # Test to validate timing semantics for JSRPC invocations with streaming responses. |
| 4 | # This test verifies that the Return event is emitted when the handler returns, |
| 5 | # NOT when the stream is fully consumed. |
| 6 | # |
| 7 | # Expected timeline: |
| 8 | # T=0: Onset event (invocation starts) |
| 9 | # T=~500ms: Return event (handler returns ReadableStream after 500ms sleep) |
| 10 | # T=~950ms: Outcome event (stream fully consumed after ~450ms more) |
| 11 | # |
| 12 | # If Return event occurs at T=~950ms instead of T=~500ms, this indicates a bug |
| 13 | # where setReturn() is called when capabilities are released rather than |
| 14 | # when the handler actually returns. |
| 15 | |
| 16 | const unitTests :Workerd.Config = ( |
| 17 | services = [ |
| 18 | (name = "jsrpc-timing-test", worker = .mainWorker), |
| 19 | (name = "tail", worker = .tailWorker), |
| 20 | ], |
| 21 | ); |
| 22 | |
| 23 | const mainWorker :Workerd.Worker = ( |
| 24 | modules = [ |
| 25 | (name = "worker", esModule = embed "jsrpc-timing-test.js") |
| 26 | ], |
| 27 | compatibilityFlags = ["nodejs_compat", "experimental", "precise_timers", "rpc", "streams_enable_constructors"], |
| 28 | bindings = [ |
| 29 | (name = "StreamingService", service = (name = "jsrpc-timing-test", entrypoint = "StreamingService")), |
| 30 | ], |
| 31 | streamingTails = ["tail"], |
| 32 | ); |
| 33 | |
| 34 | const tailWorker :Workerd.Worker = ( |
| 35 | modules = [ |
| 36 | (name = "worker", esModule = embed "jsrpc-timing-test-tail.js") |
| 37 | ], |
| 38 | compatibilityFlags = ["experimental", "nodejs_compat", "precise_timers"], |
| 39 | ); |