Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
worker: remove file extension check
Fixes: #39124
  • Loading branch information
Ayase-252 committed Aug 24, 2021
commit 81a93aa3958a6c3de5799c5a3ac1237a31b9db09
6 changes: 0 additions & 6 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -2510,12 +2510,6 @@ nor a relative path starting with `./` or `../`.

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

<a id="ERR_WORKER_UNSUPPORTED_EXTENSION"></a>
### `ERR_WORKER_UNSUPPORTED_EXTENSION`

The pathname used for the main script of a worker has an
unknown file extension.

<a id="ERR_WORKER_UNSUPPORTED_OPERATION"></a>
### `ERR_WORKER_UNSUPPORTED_OPERATION`

Expand Down
3 changes: 0 additions & 3 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1617,9 +1617,6 @@ E('ERR_WORKER_PATH', (filename) =>
TypeError);
E('ERR_WORKER_UNSERIALIZABLE_ERROR',
'Serializing an uncaught exception failed', Error);
E('ERR_WORKER_UNSUPPORTED_EXTENSION',
'The worker script extension must be ".js", ".mjs", or ".cjs". Received "%s"',
TypeError);
E('ERR_WORKER_UNSUPPORTED_OPERATION',
'%s is not supported in workers', TypeError);
E('ERR_ZLIB_INITIALIZATION_FAILED', 'Initialization failed', Error);
6 changes: 0 additions & 6 deletions lib/internal/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const {
ERR_WORKER_NOT_RUNNING,
ERR_WORKER_PATH,
ERR_WORKER_UNSERIALIZABLE_ERROR,
ERR_WORKER_UNSUPPORTED_EXTENSION,
ERR_WORKER_INVALID_EXEC_ARGV,
ERR_INVALID_ARG_TYPE,
ERR_INVALID_ARG_VALUE,
Expand Down Expand Up @@ -167,11 +166,6 @@ class Worker extends EventEmitter {
} else {
throw new ERR_WORKER_PATH(filename);
}

const ext = path.extname(filename);
if (ext !== '.js' && ext !== '.mjs' && ext !== '.cjs') {
throw new ERR_WORKER_UNSUPPORTED_EXTENSION(ext);
}
}

let env;
Expand Down
11 changes: 0 additions & 11 deletions test/parallel/test-worker-unsupported-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,6 @@ const path = require('path');
const assert = require('assert');
const { Worker } = require('worker_threads');

{
const expectedErr = {
code: 'ERR_WORKER_UNSUPPORTED_EXTENSION',
name: 'TypeError'
};
assert.throws(() => { new Worker('/b'); }, expectedErr);
assert.throws(() => { new Worker('/c.wasm'); }, expectedErr);
assert.throws(() => { new Worker('/d.txt'); }, expectedErr);
assert.throws(() => { new Worker(new URL('file:///C:/e.wasm')); }, expectedErr);
}

{
const expectedErr = {
code: 'ERR_WORKER_PATH',
Expand Down