| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -74,8 +74,6 @@ const { | |||
| 74 | 74 | ObjectKeys, | |
| 75 | 75 | ObjectSetPrototypeOf, | |
| 76 | 76 | Promise, | |
| 77 | - PromisePrototypeFinally, | ||
| 78 | - PromisePrototypeThen, | ||
| 79 | 77 | PromiseRace, | |
| 80 | 78 | ReflectApply, | |
| 81 | 79 | RegExp, | |
@@ -571,21 +569,24 @@ function REPLServer(prompt, | |||
| 571 | 569 | promise = PromiseRace([promise, interrupt]); | |
| 572 | 570 | } | |
| 573 | 571 | ||
| 574 | - PromisePrototypeFinally(PromisePrototypeThen(promise, (result) => { | ||
| 575 | - finishExecution(null, result); | ||
| 576 | - }, (err) => { | ||
| 577 | - if (err && process.domain) { | ||
| 578 | - debug('not recoverable, send to domain'); | ||
| 579 | - process.domain.emit('error', err); | ||
| 580 | - process.domain.exit(); | ||
| 581 | - return; | ||
| 572 | + (async () => { | ||
| 573 | + try { | ||
| 574 | + const result = await promise; | ||
| 575 | + finishExecution(null, result); | ||
| 576 | + } catch (err) { | ||
| 577 | + if (err && process.domain) { | ||
| 578 | + debug('not recoverable, send to domain'); | ||
| 579 | + process.domain.emit('error', err); | ||
| 580 | + process.domain.exit(); | ||
| 581 | + return; | ||
| 582 | + } | ||
| 583 | + finishExecution(err); | ||
| 584 | + } finally { | ||
| 585 | + // Remove prioritized SIGINT listener if it was not called. | ||
| 586 | + prioritizedSigintQueue.delete(sigintListener); | ||
| 587 | + unpause(); | ||
| 582 | 588 | } | |
| 583 | - finishExecution(err); | ||
| 584 | - }), () => { | ||
| 585 | - // Remove prioritized SIGINT listener if it was not called. | ||
| 586 | - prioritizedSigintQueue.delete(sigintListener); | ||
| 587 | - unpause(); | ||
| 588 | - }); | ||
| 589 | + })(); | ||
| 589 | 590 | } | |
| 590 | 591 | } | |
| 591 | 592 | ||
@@ -789,7 +790,9 @@ function REPLServer(prompt, | |||
| 789 | 790 | const prioritizedSigintQueue = new SafeSet(); | |
| 790 | 791 | self.on('SIGINT', function onSigInt() { | |
| 791 | 792 | if (prioritizedSigintQueue.size > 0) { | |
| 792 | - ArrayPrototypeForEach(prioritizedSigintQueue, (task) => task()); | ||
| 793 | + for (const task of prioritizedSigintQueue) { | ||
| 794 | + task(); | ||
| 795 | + } | ||
| 793 | 796 | return; | |
| 794 | 797 | } | |
| 795 | 798 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -164,18 +164,12 @@ async function ordinaryTests() { | |||
| 164 | 164 | } | |
| 165 | 165 | ||
| 166 | 166 | async function ctrlCTest() { | |
| 167 | - putIn.run([ | ||
| 168 | - `const timeout = (msecs) => new Promise((resolve) => { | ||
| 169 | - setTimeout(resolve, msecs).unref(); | ||
| 170 | - });`, | ||
| 171 | - ]); | ||
| 172 | - | ||
| 173 | 167 | console.log('Testing Ctrl+C'); | |
| 174 | 168 | assert.deepStrictEqual(await runAndWait([ | |
| 175 | - 'await timeout(100000)', | ||
| 169 | + 'await new Promise(() => {})', | ||
| 176 | 170 | { ctrl: true, name: 'c' }, | |
| 177 | 171 | ]), [ | |
| 178 | - 'await timeout(100000)\r', | ||
| 172 | + 'await new Promise(() => {})\r', | ||
| 179 | 173 | 'Uncaught:', | |
| 180 | 174 | '[Error [ERR_SCRIPT_EXECUTION_INTERRUPTED]: ' + | |
| 181 | 175 | 'Script execution was interrupted by `SIGINT`] {', | |
@@ -190,4 +184,4 @@ async function main() { | |||
| 190 | 184 | await ctrlCTest(); | |
| 191 | 185 | } | |
| 192 | 186 | ||
| 193 | - main(); | ||
| 187 | + main().then(common.mustCall()); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments