-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a18e674
commit 8cdb366
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]); | ||
}); | ||
}); |