Skip to content

Commit

Permalink
fix(webtransport): properly handle abruptly closed connections
Browse files Browse the repository at this point in the history
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: #688
  • Loading branch information
darrachequesne committed Oct 5, 2023
1 parent c6bf8c0 commit ff1c861
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/transports/webtransport.ts
Expand Up @@ -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 () => {
Expand Down

0 comments on commit ff1c861

Please sign in to comment.