| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 568dcc2 commit fbed90b
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -165,6 +165,7 @@ class BroadcastImpl { | |||
| 165 | 165 | ||
| 166 | 166 | function detach() { | |
| 167 | 167 | state.detached = true; | |
| 168 | + state.resolve?.({ __proto__: null, done: true, value: undefined }); | ||
| 168 | 169 | state.resolve = null; | |
| 169 | 170 | state.reject = null; | |
| 170 | 171 | if (self.#deleteConsumer(state)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -161,6 +161,18 @@ async function testCancelWithReason() { | |||
| 161 | 161 | assert.strictEqual(result.message, 'cancelled'); | |
| 162 | 162 | } | |
| 163 | 163 | ||
| 164 | + async function testPendingNextSettlesAfterReturn() { | ||
| 165 | + const { broadcast: bc } = broadcast(); | ||
| 166 | + const iter = bc.push()[Symbol.asyncIterator](); | ||
| 167 | + | ||
| 168 | + const pendingNext = iter.next(); | ||
| 169 | + await iter.return(); | ||
| 170 | + | ||
| 171 | + const result = await pendingNext; | ||
| 172 | + assert.strictEqual(result.done, true); | ||
| 173 | + assert.strictEqual(result.value, undefined); | ||
| 174 | + } | ||
| 175 | + | ||
| 164 | 176 | // ============================================================================= | |
| 165 | 177 | // Writer fail detaches consumers | |
| 166 | 178 | // ============================================================================= | |
@@ -254,6 +266,7 @@ Promise.all([ | |||
| 254 | 266 | testCancelWithoutReason(), | |
| 255 | 267 | testCancelWithReason(), | |
| 256 | 268 | testCancelWithFalsyReason(), | |
| 269 | + testPendingNextSettlesAfterReturn(), | ||
| 257 | 270 | testFailDetachesConsumers(), | |
| 258 | 271 | testWriterFailIdempotent(), | |
| 259 | 272 | testLateJoinerSeesBufferedData(), | |
| Back | FazBrowse Home | New Git URL |
0 commit comments