{"record":{"id":"72be116201fd7faf","repo":"tursodatabase/turso","slug":"statement-step-failed-with-status-status","errorCode":null,"errorMessage":"Statement step failed with status: ${status}","messagePattern":"Statement step failed with status: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"bindings/react-native/src/Statement.ts","lineNumber":264,"sourceCode":"    try {\n      // Bind parameters inside the lock to prevent concurrent bind/execute races\n      if (params.length > 0) {\n        this.bind(...params);\n      }\n\n      // Step once with async IO handling\n      const status = await this.stepWithIo();\n\n      if (status === TursoStatus.ROW) {\n        const row = this.readRow();\n        return row;\n      }\n\n      if (status === TursoStatus.DONE) {\n        return undefined;\n      }\n\n      throw new Error(`Statement step failed with status: ${status}`);\n    } finally {\n      this._statement.reset();\n      if (this._execLock) {\n        this._execLock.release();\n      }\n    }\n  }\n\n  /**\n   * Execute statement and return all rows\n   *\n   * @param params - Optional parameters to bind\n   * @returns Array of rows\n   */\n  async all(...params: BindParams[]): Promise<Row[]> {\n    if (this._finalized) {\n      throw new Error('Statement has been finalized');\n    }","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/tursodatabase/turso/blob/bad083fafbefdeae9a42ec19bdaaad8918dcf411/bindings/react-native/src/Statement.ts#L246-L282","documentation":"Statement.get() steps the statement once via stepWithIo(); TursoStatus.ROW (2) yields the row and DONE (1) yields undefined. Any other status falls through to this throw with the numeric code, which decodes against the TursoStatus enum: 4=BUSY, 5=INTERRUPT, 127=ERROR, 128=MISUSE, 133=CORRUPT, 134=IOERR. Unlike rawRun's executor path, this is a single-step read path, so failure statuses here usually mean the step itself could not be performed.","triggerScenarios":"A SELECT via stmt.get() hitting a BUSY (4) database when another connection holds the write lock; a step interrupted mid-flight (5); MISUSE (128) from stepping a statement in a bad state after abnormal bind/reset sequences; engine-level ERROR (127) from a corrupt or unreadable page.","commonSituations":"Concurrent read-during-write contention in multi-connection setups; background sync writing while the UI thread calls get(); a database file corrupted after an unclean shutdown.","solutions":["Decode the numeric status against the TursoStatus enum to identify the class of failure","Status 4 (BUSY): retry get() after a short backoff, or schedule reads outside write windows","Status 128 (MISUSE): ensure the statement was reset/rebound correctly between executions","Status 127/133/134: verify database file integrity and that the sync engine finished applying changes"],"exampleFix":"// before\ntry {\n  const row = await stmt.get(id);\n} catch (e) { /* opaque failure */ }\n\n// after\nimport { TursoStatus } from '@tursodatabase/sync-react-native';\ntry {\n  const row = await stmt.get(id);\n} catch (e) {\n  const m = /status: (\\d+)$/.exec(String(e.message));\n  if (m && Number(m[1]) === TursoStatus.BUSY) {\n    await new Promise(r => setTimeout(r, 50));\n    return await stmt.get(id); // one retry\n  }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isTursoStatusError(e: unknown): boolean {\n  return e instanceof Error && /status: \\d+$/.test(e.message);\n}","tryCatchPattern":"try {\n  const row = await stmt.get(id);\n} catch (e) {\n  const m = /status: (\\d+)$/.exec(String((e as Error).message));\n  const code = m ? Number(m[1]) : null;\n  if (code === TursoStatus.BUSY) { /* backoff and retry once */ }\n  else if (code === TursoStatus.MISUSE) { /* reset + rebind, then retry */ }\n  else throw e;\n}","preventionTips":["Decode numeric statuses against TursoStatus before deciding retry vs. fail","Retry BUSY (4) with a bounded backoff instead of failing the read","Ensure statements are reset between executions so steps never start in a bad state"],"tags":["status-code","busy","react-native","sync"],"backgroundTag":"sqlite-error-code","analyzedSha":"bad083fafbefdeae9a42ec19bdaaad8918dcf411","analyzedAt":"2026-08-16T23:12:11.798Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}