Worker threads not available — platform not supported
Production Risk
Low in standard environments; critical in embedded Node.js deployments.
Thrown when the Worker Threads API is used but the underlying V8 platform does not support workers. This can happen in embedded Node.js environments or builds where multi-threading was disabled at compile time.
- 1Using worker_threads in a custom Node.js build compiled without worker support
- 2Running Node.js in an embedded environment that does not initialise the V8 platform with worker support
Triggered when new Worker() is called but the V8 platform lacks the necessary scheduler for workers.
const { Worker } = require('worker_threads');
// On platforms built without worker support:
new Worker('./worker.js'); // throws ERR_MISSING_PLATFORM_FOR_WORKERexpected output
Error [ERR_MISSING_PLATFORM_FOR_WORKER]: The multi-threaded feature is not supported
Fix
Use a standard Node.js build with worker support
WHEN When workers are required
// Verify worker support at startup
const { isMainThread } = require('worker_threads');
if (typeof isMainThread === 'undefined') {
console.error('Worker threads not supported on this build');
process.exit(1);
}Why this works
Standard Node.js builds from nodejs.org include worker support; custom/embedded builds may not.
const { Worker } = require('worker_threads');
// On platforms built without worker support:
new Worker('./worker.js'); // throws ERR_MISSING_PLATFORM_FOR_WORKER // this triggers ERR_MISSING_PLATFORM_FOR_WORKERtry {
// operation that may throw ERR_MISSING_PLATFORM_FOR_WORKER
riskyOperation()
} catch (err) {
if (err.code === 'ERR_MISSING_PLATFORM_FOR_WORKER') {
console.error('ERR_MISSING_PLATFORM_FOR_WORKER:', err.message)
} else {
throw err
}
}// Validate inputs before calling the operation
function safe_err_missing_platform_for_worker(...args) {
// validate args here
return performOperation(...args)
}✕ Assume worker_threads is available in all environments
Embedded or custom builds may omit worker support; detect and handle gracefully.
Node.js Error Codes Documentation
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev