{"record":{"id":"0399d83a30d888bb","repo":"oven-sh/bun","slug":"variable-cannot-be-modified","errorCode":null,"errorMessage":"Variable cannot be modified.","messagePattern":"Variable cannot be modified\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bun-debug-adapter-protocol/src/debugger/adapter.ts","lineNumber":1832,"sourceCode":"      variables = await this.#getProperties(variable, start, count);\n    }\n\n    return {\n      variables: variables.sort(variablesSortBy),\n    };\n  }\n\n  async setVariable(request: DAP.SetVariableRequest): Promise<DAP.SetVariableResponse> {\n    const { variablesReference, name, value } = request;\n\n    const variable = this.#getVariable(variablesReference);\n    if (!variable) {\n      throw new Error(\"Variable not found.\");\n    }\n\n    const { objectId, objectGroup } = variable;\n    if (!objectId) {\n      throw new Error(\"Variable cannot be modified.\");\n    }\n\n    const { result, wasThrown } = await this.send(\"Runtime.callFunctionOn\", {\n      objectId,\n      functionDeclaration: `function (name) { this[name] = ${value}; return this[name]; }`,\n      arguments: [{ value: name }],\n      doNotPauseOnExceptionsAndMuteConsole: true,\n    });\n\n    if (wasThrown) {\n      throw new Error(remoteObjectToString(result));\n    }\n\n    return this.#addObject(result, { name, objectGroup });\n  }\n\n  async setExpression(request: DAP.SetExpressionRequest): Promise<DAP.SetExpressionResponse> {\n    const { expression, value, frameId } = request;","sourceCodeStart":1814,"sourceCodeEnd":1850,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/packages/bun-debug-adapter-protocol/src/debugger/adapter.ts#L1814-L1850","documentation":"Error \"Variable cannot be modified.\" thrown in oven-sh/bun.","triggerScenarios":"Thrown at packages/bun-debug-adapter-protocol/src/debugger/adapter.ts:1832 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}