{"record":{"id":"6bd1624b1066e7c0","repo":"tursodatabase/turso","slug":"unexpected-status-from-operation-resume-statu","errorCode":null,"errorMessage":"Unexpected status from operation.resume(): ${status}","messagePattern":"Unexpected status from operation\\.resume\\(\\): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"bindings/react-native/src/internal/asyncOperation.ts","lineNumber":77,"sourceCode":"        default:\n          throw new Error(`Unknown result type: ${resultKind}`);\n      }\n    }\n\n    // Operation needs IO\n    if (status === TursoStatus.IO) {\n      // Process all pending IO items\n      await processIoQueue(database, context);\n\n      // Step callbacks after IO processing\n      database.ioStepCallbacks();\n\n      // Continue resume loop\n      continue;\n    }\n\n    // Any other status is an error\n    throw new Error(`Unexpected status from operation.resume(): ${status}`);\n  }\n}\n\n/**\n * Process all pending IO items in the queue\n *\n * @param database - The native sync database\n * @param context - IO context with auth and URL information\n */\nasync function processIoQueue(database: NativeSyncDatabase, context: IoContext): Promise<void> {\n  const promises: Promise<void>[] = [];\n\n  // Take all available IO items from the queue\n  while (true) {\n    const ioItem = database.ioTakeItem();\n    if (!ioItem) {\n      break; // No more items\n    }","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/react-native/src/internal/asyncOperation.ts#L59-L95","documentation":"driveOperation() loops operation.resume() and only two outcomes are progress: DONE (finished) and IO (needs IO, handled by processing the IO queue). Any other TursoStatus aborts with this error - it is the generic failure exit for every async sync operation (connect, pull, push, sync). The numeric status is the engine's reason; the true root cause is usually visible just before it, in a '[Turso HTTP] Request failed:' log or a poisoned IO item.","triggerScenarios":"db.connect()/pull()/push()/sync() where the underlying native operation fails: a prior HTTP or file IO item was poisoned with an error (network fetch rejected, file read failed), the engine returned ERROR(127)/MISUSE(128)/BUSY(4), or arguments to the operation were invalid.","commonSituations":"Device offline or token rejected during a sync bootstrap; a corrupt local replica making the engine fail mid-operation; a custom file-system shim throwing; calling sync operations against a database opened purely locally by mistake.","solutions":["Map the number against TursoStatus (4=BUSY, 5=INTERRUPT, 6=BUSY_SNAPSHOT, 127=ERROR, 128=MISUSE, 130=READONLY, 133=CORRUPT, 134=IOERR) to narrow the cause","Look for the console.error output from ioProcessor just before the throw - it names the failing URL/operation that poisoned the IO item","Verify url/authToken in the connect options and device connectivity, then retry the operation on a fresh connection","For CORRUPT/NOTADB-class causes, delete the local replica file and reconnect to re-bootstrap"],"exampleFix":"// before\nawait db.pull(); // 'Unexpected status from operation.resume(): 127'\n\n// after - retry once on a fresh connection, surface root cause on repeat failure\nasync function pullWithRetry(db, opts) {\n  try {\n    return await db.pull();\n  } catch (e) {\n    console.warn('sync failed, reconnecting:', e.message);\n    await db.close();\n    const fresh = await connect(opts);\n    return fresh.pull();\n  }\n}","handlingStrategy":"retry","validationCode":"// Cheap pre-flight: a sync round-trip exposes network/auth problems with a clear error\nexport async function assertSyncHealthy(db: Database): Promise<void> {\n  await db.sync();\n}","typeGuard":null,"tryCatchPattern":"catch (e) { if (e instanceof Error && e.message.includes('operation.resume()')) { await db.close(); db = await connect(opts); return db.pull(); // one retry on a fresh connection } throw e; }","preventionTips":["Watch for '[Turso HTTP] Request failed:' console output - it names the root cause behind the opaque status number","Keep a TursoStatus lookup table when handling sync errors (127=ERROR, 128=MISUSE, 133=CORRUPT, 134=IOERR)","Validate url/authToken before connect so MISUSE-class statuses never start an operation"],"tags":["react-native","sync","native-status","network","operations"],"backgroundTag":"sync-operation-failed","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"}