Skip to content

Commit 16271d2

Browse files
Ayase-252targos
authored andcommitted
worker: remove file extension check
Fixes: #39124 PR-URL: #39788 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 9270684 commit 16271d2

File tree

4 files changed

+0
-26
lines changed

4 files changed

+0
-26
lines changed

doc/api/errors.md

-6
Original file line numberDiff line numberDiff line change
@@ -2502,12 +2502,6 @@ nor a relative path starting with `./` or `../`.
25022502

25032503
All attempts at serializing an uncaught exception from a worker thread failed.
25042504

2505-
<a id="ERR_WORKER_UNSUPPORTED_EXTENSION"></a>
2506-
### `ERR_WORKER_UNSUPPORTED_EXTENSION`
2507-
2508-
The pathname used for the main script of a worker has an
2509-
unknown file extension.
2510-
25112505
<a id="ERR_WORKER_UNSUPPORTED_OPERATION"></a>
25122506
### `ERR_WORKER_UNSUPPORTED_OPERATION`
25132507

lib/internal/errors.js

-3
Original file line numberDiff line numberDiff line change
@@ -1617,9 +1617,6 @@ E('ERR_WORKER_PATH', (filename) =>
16171617
TypeError);
16181618
E('ERR_WORKER_UNSERIALIZABLE_ERROR',
16191619
'Serializing an uncaught exception failed', Error);
1620-
E('ERR_WORKER_UNSUPPORTED_EXTENSION',
1621-
'The worker script extension must be ".js", ".mjs", or ".cjs". Received "%s"',
1622-
TypeError);
16231620
E('ERR_WORKER_UNSUPPORTED_OPERATION',
16241621
'%s is not supported in workers', TypeError);
16251622
E('ERR_ZLIB_INITIALIZATION_FAILED', 'Initialization failed', Error);

lib/internal/worker.js

-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ const {
3535
ERR_WORKER_NOT_RUNNING,
3636
ERR_WORKER_PATH,
3737
ERR_WORKER_UNSERIALIZABLE_ERROR,
38-
ERR_WORKER_UNSUPPORTED_EXTENSION,
3938
ERR_WORKER_INVALID_EXEC_ARGV,
4039
ERR_INVALID_ARG_TYPE,
4140
ERR_INVALID_ARG_VALUE,
@@ -167,11 +166,6 @@ class Worker extends EventEmitter {
167166
} else {
168167
throw new ERR_WORKER_PATH(filename);
169168
}
170-
171-
const ext = path.extname(filename);
172-
if (ext !== '.js' && ext !== '.mjs' && ext !== '.cjs') {
173-
throw new ERR_WORKER_UNSUPPORTED_EXTENSION(ext);
174-
}
175169
}
176170

177171
let env;

test/parallel/test-worker-unsupported-path.js

-11
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,6 @@ const path = require('path');
55
const assert = require('assert');
66
const { Worker } = require('worker_threads');
77

8-
{
9-
const expectedErr = {
10-
code: 'ERR_WORKER_UNSUPPORTED_EXTENSION',
11-
name: 'TypeError'
12-
};
13-
assert.throws(() => { new Worker('/b'); }, expectedErr);
14-
assert.throws(() => { new Worker('/c.wasm'); }, expectedErr);
15-
assert.throws(() => { new Worker('/d.txt'); }, expectedErr);
16-
assert.throws(() => { new Worker(new URL('file:///C:/e.wasm')); }, expectedErr);
17-
}
18-
198
{
209
const expectedErr = {
2110
code: 'ERR_WORKER_PATH',

0 commit comments

Comments
 (0)