Skip to content

Commit

Permalink
Add regression test for #66
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiasBuelens committed Nov 11, 2020
1 parent a18e674 commit 8cdb366
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/unit/readable-stream/regression.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { TransformStream } = require('../../../');

describe('ReadableStream regressions', () => {
// https://github.com/MattiasBuelens/web-streams-polyfill/issues/66
it('#66', async () => {
const { readable, writable } = new TransformStream();

const producer = (async () => {
const writer = writable.getWriter();
await writer.write('hello');
// The async iterator releases its reader lock in the "close steps" of its pending read, which rejects the
// reader's closed promise. However, ReadableStreamClose then tries to resolve that same closed promise.
// This *should* be ignored (since the promise is already rejected), but instead would cause a TypeError.
await writer.close();
})();

const consumer = (async () => {
const results = [];
for await (const chunk of readable) {
results.push(chunk);
}
expect(results).toEqual(['hello']);
})();

await Promise.all([producer, consumer]);
});
});

0 comments on commit 8cdb366

Please sign in to comment.