Skip to content

Commit ff1c861

Browse files
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: #688
1 parent c6bf8c0 commit ff1c861

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/transports/webtransport.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ export class WebTransport extends Transport {
1414
super({ _query: { EIO: "4" } });
1515

1616
const transformStream = createPacketEncoderStream();
17-
transformStream.readable.pipeTo(stream.writable);
17+
transformStream.readable.pipeTo(stream.writable).catch(() => {
18+
debug("the stream was closed");
19+
});
1820
this.writer = transformStream.writable.getWriter();
1921

2022
(async () => {

0 commit comments

Comments
 (0)