Skip to content

Commit a8ffbcd

Browse files
committed
worker: make Worker async disposable
Manual Backport of #58385 Original metadata: PR-URL: #58385 Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 6b37fa8 commit a8ffbcd

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

lib/internal/worker.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const {
1919
String,
2020
StringPrototypeTrim,
2121
Symbol,
22-
SymbolAsyncDispose,
2322
SymbolFor,
2423
TypedArrayPrototypeFill,
2524
Uint32Array,
@@ -60,7 +59,7 @@ const {
6059
const { createMainThreadPort, destroyMainThreadPort } = require('internal/worker/messaging');
6160
const { deserializeError } = require('internal/error_serdes');
6261
const { fileURLToPath, isURL, pathToFileURL } = require('internal/url');
63-
const { kEmptyObject } = require('internal/util');
62+
const { kEmptyObject, SymbolAsyncDispose } = require('internal/util');
6463
const { validateArray, validateString } = require('internal/validators');
6564
const {
6665
throwIfBuildingSnapshot,

test/parallel/test-worker-dispose.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as common from '../common/index.mjs';
22
import { Worker } from 'node:worker_threads';
33

4-
// Verifies that the worker is async disposable
5-
await using worker = new Worker('for(;;) {}', { eval: true });
4+
// Verifies that the worker is async disposable.
5+
const worker = new Worker('for(;;) {}', { eval: true });
66
worker.on('exit', common.mustCall());
7-
worker[Symbol.dispose]();
7+
await worker[Symbol.asyncDispose]();

0 commit comments

Comments
 (0)