oven-sh/bun · error · Error

Variable cannot be modified.

Error message

Variable cannot be modified.

What it means

Error "Variable cannot be modified." thrown in oven-sh/bun.

Source

Thrown at packages/bun-debug-adapter-protocol/src/debugger/adapter.ts:1832

      variables = await this.#getProperties(variable, start, count);
    }

    return {
      variables: variables.sort(variablesSortBy),
    };
  }

  async setVariable(request: DAP.SetVariableRequest): Promise<DAP.SetVariableResponse> {
    const { variablesReference, name, value } = request;

    const variable = this.#getVariable(variablesReference);
    if (!variable) {
      throw new Error("Variable not found.");
    }

    const { objectId, objectGroup } = variable;
    if (!objectId) {
      throw new Error("Variable cannot be modified.");
    }

    const { result, wasThrown } = await this.send("Runtime.callFunctionOn", {
      objectId,
      functionDeclaration: `function (name) { this[name] = ${value}; return this[name]; }`,
      arguments: [{ value: name }],
      doNotPauseOnExceptionsAndMuteConsole: true,
    });

    if (wasThrown) {
      throw new Error(remoteObjectToString(result));
    }

    return this.#addObject(result, { name, objectGroup });
  }

  async setExpression(request: DAP.SetExpressionRequest): Promise<DAP.SetExpressionResponse> {
    const { expression, value, frameId } = request;

View on GitHub (pinned to 8c5296ac45)

When it happens

Trigger: Thrown at packages/bun-debug-adapter-protocol/src/debugger/adapter.ts:1832 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/0399d83a30d888bb. Report an issue: GitHub.