| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d33f4b5 commit 411cc42
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2770,12 +2770,15 @@ legacy parser. | |||
| 2770 | 2770 | ||
| 2771 | 2771 | <!-- YAML | |
| 2772 | 2772 | changes: | |
| 2773 | + - version: REPLACEME | ||
| 2774 | + pr-url: https://github.com/nodejs/node/pull/58528 | ||
| 2775 | + description: End-of-Life. | ||
| 2773 | 2776 | - version: v12.5.0 | |
| 2774 | 2777 | pr-url: https://github.com/nodejs/node/pull/28021 | |
| 2775 | 2778 | description: Runtime deprecation. | |
| 2776 | 2779 | --> | |
| 2777 | 2780 | ||
| 2778 | - Type: Runtime | ||
| 2781 | + Type: End-of-Life | ||
| 2779 | 2782 | ||
| 2780 | 2783 | Passing a callback to [`worker.terminate()`][] is deprecated. Use the returned | |
| 2781 | 2784 | `Promise` instead, or a listener to the worker's `'exit'` event. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,6 +11,7 @@ const { | |||
| 11 | 11 | ObjectEntries, | |
| 12 | 12 | Promise, | |
| 13 | 13 | PromiseResolve, | |
| 14 | + PromiseWithResolvers, | ||
| 14 | 15 | ReflectApply, | |
| 15 | 16 | RegExpPrototypeExec, | |
| 16 | 17 | SafeArrayIterator, | |
@@ -381,30 +382,21 @@ class Worker extends EventEmitter { | |||
| 381 | 382 | ReflectApply(this[kPublicPort].postMessage, this[kPublicPort], args); | |
| 382 | 383 | } | |
| 383 | 384 | ||
| 384 | - terminate(callback) { | ||
| 385 | + terminate() { | ||
| 385 | 386 | debug(`[${threadId}] terminates Worker with ID ${this.threadId}`); | |
| 386 | 387 | ||
| 387 | 388 | this.ref(); | |
| 388 | 389 | ||
| 389 | - if (typeof callback === 'function') { | ||
| 390 | - process.emitWarning( | ||
| 391 | - 'Passing a callback to worker.terminate() is deprecated. ' + | ||
| 392 | - 'It returns a Promise instead.', | ||
| 393 | - 'DeprecationWarning', 'DEP0132'); | ||
| 394 | - if (this[kHandle] === null) return PromiseResolve(); | ||
| 395 | - this.once('exit', (exitCode) => callback(null, exitCode)); | ||
| 396 | - } | ||
| 397 | - | ||
| 398 | 390 | if (this[kHandle] === null) return PromiseResolve(); | |
| 399 | 391 | ||
| 400 | 392 | this[kHandle].stopThread(); | |
| 401 | 393 | ||
| 402 | 394 | // Do not use events.once() here, because the 'exit' event will always be | |
| 403 | 395 | // emitted regardless of any errors, and the point is to only resolve | |
| 404 | 396 | // once the thread has actually stopped. | |
| 405 | - return new Promise((resolve) => { | ||
| 406 | - this.once('exit', resolve); | ||
| 407 | - }); | ||
| 397 | + const { promise, resolve } = PromiseWithResolvers(); | ||
| 398 | + this.once('exit', resolve); | ||
| 399 | + return promise; | ||
| 408 | 400 | } | |
| 409 | 401 | ||
| 410 | 402 | async [SymbolAsyncDispose]() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,14 +12,6 @@ process.nextTick(() => { | |||
| 12 | 12 | }); | |
| 13 | 13 | `, { eval: true }); | |
| 14 | 14 | ||
| 15 | - // Test deprecation of .terminate() with callback. | ||
| 16 | - common.expectWarning( | ||
| 17 | - 'DeprecationWarning', | ||
| 18 | - 'Passing a callback to worker.terminate() is deprecated. ' + | ||
| 19 | - 'It returns a Promise instead.', 'DEP0132'); | ||
| 20 | - | ||
| 21 | 15 | w.on('message', common.mustCall(() => { | |
| 22 | - setTimeout(() => { | ||
| 23 | - w.terminate(common.mustCall()).then(common.mustCall()); | ||
| 24 | - }, 1); | ||
| 16 | + setTimeout(() => w.terminate().then(common.mustCall()), 1); | ||
| 25 | 17 | })); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,9 +15,7 @@ process.once('beforeExit', common.mustCall(() => worker.ref())); | |||
| 15 | 15 | ||
| 16 | 16 | worker.on('exit', common.mustCall(() => { | |
| 17 | 17 | worker.terminate().then((res) => assert.strictEqual(res, undefined)); | |
| 18 | - worker.terminate(() => null).then( | ||
| 19 | - (res) => assert.strictEqual(res, undefined) | ||
| 20 | - ); | ||
| 18 | + | ||
| 21 | 19 | })); | |
| 22 | 20 | ||
| 23 | 21 | worker.unref(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments