ERR_WASI_NOT_STARTED
Node.jsERRORCriticalWASIHIGH confidence

WASI instance has not been started

Production Risk

Low — WASI is specialised; follow the start() → execute lifecycle strictly.

What this means

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.

Why it happens
  1. 1Calling a WASI method that requires an active instance before calling wasi.start()
  2. 2Logic error where wasi.start() is skipped or conditional
How to reproduce

Triggered when a WASI instance operation is attempted before start() has been called.

trigger — this will error
trigger — this will error
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

Ensure wasi.start() is called before any dependent operations
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 operations

Why this works

Calling start() initiates the WASI execution environment; dependent operations succeed after this.

Code examples
Triggerjs
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_STARTED
Handle in try/catchjs
try {
  // 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
  }
}
Defensive pattern to avoid itjs
// Validate inputs before calling the operation
function safe_err_wasi_not_started(...args) {
  // validate args here
  return performOperation(...args)
}
What not to do

Use WASI methods before calling start() or initialize()

WASI state is not initialised until start() is called; pre-start operations are invalid.

Sources
Official documentation ↗

Node.js Error Codes Documentation

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Node.js errors