| 403 | |
| 404 | it("memoizes module results and enforces single-consumer handles", async () => { |
| 405 | const sourceEvents = () => |
| 406 | new ReadableStream<import("./runtime/types.js").WorkspaceRuntimeEvent>({ |
| 407 | start(controller) { |
| 408 | controller.enqueue({ |
| 409 | id: "module-exec", |
| 410 | seq: 1, |
| 411 | name: "stdout", |
| 412 | value: new TextEncoder().encode("hello"), |
| 413 | }); |
| 414 | controller.enqueue({ |
| 415 | id: "module-exec", |
| 416 | seq: 2, |
| 417 | name: "stdout", |
| 418 | value: new Uint8Array([0xe2]), |
| 419 | }); |
| 420 | controller.enqueue({ id: "module-exec", seq: 3, name: "result", value: 42 }); |
| 421 | controller.enqueue({ id: "module-exec", seq: 4, name: "exit", value: 0 }); |
| 422 | controller.close(); |
| 423 | }, |
| 424 | }); |
| 425 | let replayCalls = 0; |
| 426 | const backend: WorkspaceModuleBackend = { |
| 427 | protocol: "module", |