{"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/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/react-native/src/Statement.ts#L246-L282","documentation":"In get(), after stepWithIo() the status must be ROW (row available) or DONE (no rows); any other status — beyond the IO case already handled inside stepWithIo — throws with the numeric code. This wraps native step failures that are neither a row nor completion.","triggerScenarios":"A SELECT whose native step returns an unexpected status code (native error/invalid state), typically after earlier errors invalidated the statement or connection, or from a version mismatch between the JS package and the compiled native library.","commonSituations":"Rare; appears alongside native-layer faults. Most often when the app was partially upgraded (new JS, old native binary) or after a prior error on the same connection left it in a bad state. The status number in the message is the key diagnostic.","solutions":["Log the status code and SQL; reproduce with db.exec/db.all to see if it is statement-specific or connection-wide","Rebuild the native app so JS and native layers come from the same release of the package","Recover by closing and reopening the Database (new connection state)","If reproducible on current versions, file an issue with the minimal SQL and status code"],"exampleFix":"// before\nconst user = await db.get('SELECT * FROM users WHERE id = ?', [id]); // throws status error\n\n// after: fail soft and reset the connection once\nlet user;\ntry {\n  user = await db.get('SELECT * FROM users WHERE id = ?', [id]);\n} catch (e) {\n  await resetDatabaseConnection(); // close, new Database, connect\n  user = await db.get('SELECT * FROM users WHERE id = ?', [id]);\n}","handlingStrategy":"retry","validationCode":"// Cheap connection probe before reads that matter\nawait db.get('SELECT 1');\nconst user = await db.get('SELECT * FROM users WHERE id = ?', [id]);","typeGuard":null,"tryCatchPattern":"try {\n  return await db.get(sql, params);\n} catch (e) {\n  if (e instanceof Error && /step failed with status/.test(e.message)) {\n    await resetDatabaseConnection(); // close + new Database + connect\n    return db.get(sql, params); // single retry on clean state\n  }\n  throw e;\n}","preventionTips":["Rebuild native and JS together on upgrades; version skew produces these status escapes","Always capture the status code and SQL in error reporting for native triage","Don't loop retries on this error — one recovery attempt, then surface"],"tags":["react-native","statement","native-error","step-status","get"],"backgroundTag":"statement-status-error","analyzedSha":"244cde92a7df7f9b8b8b7a4075c35a12977e303e","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}