Description:
In messenger.ts, the sendRequest function creates a responsePromise that waits indefinitely for a response:${request.id} event on RPCResponseObserver. If the Deno subprocess never returns a response, the promise remains pending and the caller is blocked. Additionally, the request id is generated using Math.random(), which is not ideal for unique IDs.
Expected behavior:
sendRequest should reject after a reasonable timeout and clean up the event listener, so pending requests cannot leak or hang the process forever.
Suggested fix:
Race the response promise against a setTimeout promise.
Remove the event listener in both the success/timeout cases.
Consider replacing the Math.random() id with crypto.randomUUID() or a sequential/counter-based id.
Description:
In messenger.ts, the sendRequest function creates a responsePromise that waits indefinitely for a response:${request.id} event on RPCResponseObserver. If the Deno subprocess never returns a response, the promise remains pending and the caller is blocked. Additionally, the request id is generated using Math.random(), which is not ideal for unique IDs.
Expected behavior:
sendRequest should reject after a reasonable timeout and clean up the event listener, so pending requests cannot leak or hang the process forever.
Suggested fix:
Race the response promise against a setTimeout promise.
Remove the event listener in both the success/timeout cases.
Consider replacing the Math.random() id with crypto.randomUUID() or a sequential/counter-based id.