fix(webtransport): properly handle abruptly closed connections

Refreshing the page with a client connected with WebTransport would
trigger the following exception:

> node:internal/process/promises:288
>            triggerUncaughtException(err, true /* fromPromise */);
>            ^
>
> [UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "0".] {
>   code: 'ERR_UNHANDLED_REJECTION'
> }

Related: https://github.com/socketio/engine.io/issues/688
This commit is contained in:
Damien Arrachequesne
2023-10-05 16:56:11 +02:00
parent c6bf8c0f57
commit ff1c861548

View File

@@ -14,7 +14,9 @@ export class WebTransport extends Transport {
super({ _query: { EIO: "4" } });
const transformStream = createPacketEncoderStream();
transformStream.readable.pipeTo(stream.writable);
transformStream.readable.pipeTo(stream.writable).catch(() => {
debug("the stream was closed");
});
this.writer = transformStream.writable.getWriter();
(async () => {