Skip to content

Commit

Permalink
worker: remove file extension check
Browse files Browse the repository at this point in the history
Fixes: #39124

PR-URL: #39788
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
Ayase-252 authored and targos committed Sep 6, 2021
1 parent 9270684 commit 16271d2
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 26 deletions.
6 changes: 0 additions & 6 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -2502,12 +2502,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

0 comments on commit 16271d2

Please sign in to comment.