-
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.
Merge pull request #67 from MattiasBuelens/fix-resolve-after-reject
Ignore resolving/rejecting promises after a previous resolve/reject
- Loading branch information
Showing
4 changed files
with
52 additions
and
18 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
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
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
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]); | ||
}); | ||
}); |