| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1911,9 +1911,12 @@ function readableStreamDefaultControllerError(controller, error) { | |||
| 1911 | 1911 | ||
| 1912 | 1912 | function readableStreamDefaultControllerCancelSteps(controller, reason) { | |
| 1913 | 1913 | resetQueue(controller); | |
| 1914 | - const result = controller[kState].cancelAlgorithm(reason); | ||
| 1915 | - readableStreamDefaultControllerClearAlgorithms(controller); | ||
| 1916 | - return result; | ||
| 1914 | + try { | ||
| 1915 | + const result = controller[kState].cancelAlgorithm(reason); | ||
| 1916 | + return result; | ||
| 1917 | + } finally { | ||
| 1918 | + readableStreamDefaultControllerClearAlgorithms(controller); | ||
| 1919 | + } | ||
| 1917 | 1920 | } | |
| 1918 | 1921 | ||
| 1919 | 1922 | function readableStreamDefaultControllerPullSteps(controller, readRequest) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -80,6 +80,36 @@ const { | |||
| 80 | 80 | assert(r.locked); | |
| 81 | 81 | } | |
| 82 | 82 | ||
| 83 | + { | ||
| 84 | + // Throw error and return rejected promise in `cancel()` method | ||
| 85 | + // would execute same cleanup code | ||
| 86 | + const r1 = new ReadableStream({ | ||
| 87 | + cancel: () => { | ||
| 88 | + return Promise.reject('Cancel Error'); | ||
| 89 | + }, | ||
| 90 | + }); | ||
| 91 | + r1.cancel().finally(common.mustCall(() => { | ||
| 92 | + const controllerState = r1[kState].controller[kState]; | ||
| 93 | + | ||
| 94 | + assert.strictEqual(controllerState.pullAlgorithm, undefined); | ||
| 95 | + assert.strictEqual(controllerState.cancelAlgorithm, undefined); | ||
| 96 | + assert.strictEqual(controllerState.sizeAlgorithm, undefined); | ||
| 97 | + })).catch(() => {}); | ||
| 98 | + | ||
| 99 | + const r2 = new ReadableStream({ | ||
| 100 | + cancel() { | ||
| 101 | + throw new Error('Cancel Error'); | ||
| 102 | + } | ||
| 103 | + }); | ||
| 104 | + r2.cancel().finally(common.mustCall(() => { | ||
| 105 | + const controllerState = r2[kState].controller[kState]; | ||
| 106 | + | ||
| 107 | + assert.strictEqual(controllerState.pullAlgorithm, undefined); | ||
| 108 | + assert.strictEqual(controllerState.cancelAlgorithm, undefined); | ||
| 109 | + assert.strictEqual(controllerState.sizeAlgorithm, undefined); | ||
| 110 | + })).catch(() => {}); | ||
| 111 | + } | ||
| 112 | + | ||
| 83 | 113 | { | |
| 84 | 114 | const source = { | |
| 85 | 115 | start: common.mustCall((controller) => { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments