Skip to content

Commit

Permalink
Avoid exceptions in the console with ill-formed flate streams
Browse files Browse the repository at this point in the history
It fixes mozilla#18876.
  • Loading branch information
calixteman committed Oct 10, 2024
1 parent 233ac17 commit 0d64bf7
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/core/flate_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,19 @@ class FlateStream extends DecodeStream {
try {
const { readable, writable } = new DecompressionStream("deflate");
const writer = writable.getWriter();
writer.write(bytes);
writer.close();
await writer.ready;

// We can't await writer.write() because it'll block until the reader
// starts which happens few lines below.
writer
.write(bytes)
.then(async () => {
try {
await writer.ready;
await writer.close();
} catch {}
})
.catch(() => {});

const chunks = [];
let totalLength = 0;
Expand Down

0 comments on commit 0d64bf7

Please sign in to comment.