{"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/bad083fafbefdeae9a42ec19bdaaad8918dcf411/bindings/react-native/src/internal/asyncOperation.ts#L59-L95","documentation":"runOperation()'s resume loop accepts exactly two statuses: DONE means the operation finished and its result can be extracted, and IO means pending IO items must be processed (processIoQueue + ioStepCallbacks) before resuming. Every other status — BUSY(4), INTERRUPT(5), ERROR(127), etc. — exits through this throw with the numeric code. It is the generic failure exit for async sync-engine operations such as connect() and sync().","triggerScenarios":"connect() against an unreachable or misconfigured sync URL; auth rejected during a sync operation; BUSY (4) when the sync engine contends with another connection; an interrupted operation during teardown.","commonSituations":"Bad or missing url/authToken passed to connect(); serverless endpoint offline or returning errors the engine maps to 127; app backgrounding mid-sync causing interrupts; concurrent sync sessions.","solutions":["Decode the numeric status against the TursoStatus enum (types.ts) to classify the failure","Verify connect() options: url is a valid reachable endpoint and authToken is set when required","Status 4 (BUSY): serialize sync operations / retry after a short backoff","Status 127 with valid config: inspect the ioProcessor logs for the failing HTTP exchange and report if the server response looks valid"],"exampleFix":"// before\nconst db = await connect({ path }); // throws: Unexpected status from operation.resume(): 127\n\n// after\nconst db = await connect({\n  path,\n  url: process.env.TURSO_SYNC_URL,   // required sync endpoint\n  authToken: process.env.TURSO_AUTH_TOKEN,\n});","handlingStrategy":"retry","validationCode":"// Validate connect() inputs before starting any sync operation\nfunction assertSyncConfig(opts: { url?: string; authToken?: string }): void {\n  if (!opts.url || !/^https?:\\/\\//.test(normalizeUrl(opts.url))) {\n    throw new Error('connect() requires a valid http(s) sync url');\n  }\n}","typeGuard":"function isResumeStatusError(e: unknown): { code: number } | null {\n  const m = /operation\\.resume\\(\\): (\\d+)$/.exec(e instanceof Error ? e.message : '');\n  return m ? { code: Number(m[1]) } : null;\n}","tryCatchPattern":"try {\n  await db.sync();\n} catch (e) {\n  const s = isResumeStatusError(e);\n  if (s && s.code === TursoStatus.BUSY) {\n    await new Promise(r => setTimeout(r, 100));\n    return db.sync(); // bounded retry\n  }\n  throw e; // 127 etc. → inspect config/logs before retrying blindly\n}","preventionTips":["Validate url/authToken before connect(); don't let undefined slip into options","Decode numeric resume statuses with the TursoStatus enum","Retry only transient codes (BUSY); investigate ERROR(127) via ioProcessor logs"],"tags":["status-code","sync-operation","configuration","react-native"],"backgroundTag":"sync-operation-failed","analyzedSha":"bad083fafbefdeae9a42ec19bdaaad8918dcf411","analyzedAt":"2026-08-16T23:12:11.798Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}