WASI instance has not been started
Production Risk
Low — WASI is specialised; follow the start() → execute lifecycle strictly.
Thrown when a WASI instance operation requires the instance to have been started, but start() or initialize() has not yet been called. Some WASI operations are only valid after the instance is running.
- 1Calling a WASI method that requires an active instance before calling wasi.start()
- 2Logic error where wasi.start() is skipped or conditional
Triggered when a WASI instance operation is attempted before start() has been called.
const { WASI } = require('wasi');
const wasi = new WASI();
// Attempting to use wasiImport before starting
// (illustrative — actual trigger depends on internal method order)expected output
Error [ERR_WASI_NOT_STARTED]: WASI instance has not yet started
Fix
Ensure wasi.start() is called before any dependent operations
WHEN When using WASI instance methods
const wasi = new WASI({ args: [], env: {} });
const importObject = { wasi_snapshot_preview1: wasi.wasiImport };
const { instance } = WebAssembly.instantiateSync(wasmBuffer, importObject);
wasi.start(instance); // must be called before module-dependent operationsWhy this works
Calling start() initiates the WASI execution environment; dependent operations succeed after this.
const { WASI } = require('wasi');
const wasi = new WASI();
// Attempting to use wasiImport before starting
// (illustrative — actual trigger depends on internal method order) // this triggers ERR_WASI_NOT_STARTEDtry {
// operation that may throw ERR_WASI_NOT_STARTED
riskyOperation()
} catch (err) {
if (err.code === 'ERR_WASI_NOT_STARTED') {
console.error('ERR_WASI_NOT_STARTED:', err.message)
} else {
throw err
}
}// Validate inputs before calling the operation
function safe_err_wasi_not_started(...args) {
// validate args here
return performOperation(...args)
}✕ Use WASI methods before calling start() or initialize()
WASI state is not initialised until start() is called; pre-start operations are invalid.
Node.js Error Codes Documentation
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev