{"record":{"id":"8fcaa232ff927fba","repo":"tursodatabase/turso","slug":"http-request-failed-e-instanceof-error-e-mess","errorCode":null,"errorMessage":"HTTP request failed: ${e instanceof Error ? e.message : String(e)}. URL: ${fullUrl}, Method: ${request.method}, Body size: ${request.body ? request.body.byteLength : 0} bytes","messagePattern":"HTTP request failed: (.+?)\\. URL: (.+?), Method: (.+?), Body size: (.+?) bytes","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"bindings/react-native/src/internal/ioProcessor.ts","lineNumber":217,"sourceCode":"  let response;\n  try {\n    response = await fetch(fullUrl, options);\n  } catch (e) {\n    // Detailed error logging\n    const errorDetails = {\n      url: fullUrl,\n      method: request.method,\n      hasBody: !!request.body,\n      bodySize: request.body ? request.body.byteLength : 0,\n      bodyType: request.body ? Object.prototype.toString.call(options.body) : 'none',\n      error: e instanceof Error ? {\n        message: e.message,\n        name: e.name,\n        stack: e.stack,\n      } : String(e),\n    };\n    console.error('[Turso HTTP] Request failed:', JSON.stringify(errorDetails, null, 2));\n    throw new Error(`HTTP request failed: ${e instanceof Error ? e.message : String(e)}. URL: ${fullUrl}, Method: ${request.method}, Body size: ${request.body ? request.body.byteLength : 0} bytes`);\n  }\n\n\n  // Set status code\n  item.setStatus(response.status);\n\n  // Read response body and push to item\n  const responseData = await response.arrayBuffer();\n  if (responseData.byteLength > 0) {\n    item.pushBuffer(responseData);\n  }\n\n  // Mark as done\n  item.done();\n}\n\n/**\n * Process a full read request (atomic file read)","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/react-native/src/internal/ioProcessor.ts#L199-L235","documentation":"This is the SDK's wrapper around a failed fetch() for a sync-engine HTTP request: the message embeds the underlying error, the resolved URL, the HTTP method and the body size, and ioProcessor also logs a full '[Turso HTTP] Request failed:' JSON blob to the console. The failing IO item is then poisoned, so the surrounding operation usually dies right after with 'Unexpected status from operation.resume()'. This error is where the real network diagnosis happens.","triggerScenarios":"connect()/pull()/push()/sync() (or any query on a partial-sync replica that must fetch missing pages) while fetch() throws: DNS failure, TLS error, connection refused, Android missing the INTERNET permission, iOS ATS blocking a plain-http URL, or an emulator hitting localhost instead of 10.0.2.2.","commonSituations":"Airplane mode / flaky mobile data during sync; local dev server reached via localhost from the Android emulator (use 10.0.2.2); release Android builds without android.permission.INTERNET; http:// (non-TLS) endpoints rejected by iOS App Transport Security; corporate proxies interfering with libsql://-style endpoints normalized to https://.","solutions":["Read the embedded URL and underlying message - they tell you exactly which endpoint and which network failure (DNS, TLS, refused)","Android: confirm <uses-permission android:name=\"android.permission.INTERNET\"/> in AndroidManifest.xml, and use 10.0.2.2 (not localhost) when targeting a dev machine from the emulator","iOS: use https:// endpoints or add an ATS exception for your dev host","Retry the operation with backoff once connectivity returns; on repeated auth-adjacent failures, verify the authToken is valid for that database"],"exampleFix":"// before - emulator cannot reach localhost\nconst db = await connect({ path: 'r.db', url: 'http://localhost:8080' });\n\n// after\nimport { Platform } from 'react-native';\nconst host = Platform.OS === 'android' && __DEV__ ? '10.0.2.2' : 'myserver.example.com';\nconst db = await connect({ path: 'r.db', url: `https://${host}` });","handlingStrategy":"retry","validationCode":"// Connectivity pre-flight before sync operations on mobile\nexport async function isOnline(): Promise<boolean> {\n  try {\n    const res = await fetch('https://your-db-host/ping', { method: 'HEAD' });\n    return res.ok || res.status < 500;\n  } catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"catch (e) { if (e instanceof Error && e.message.startsWith('HTTP request failed:')) { await backoff(++attempt); return db.pull(); // retry with backoff while online } throw e; }","preventionTips":["Add android.permission.INTERNET to AndroidManifest.xml before first run","Use 10.0.2.2 (not localhost) for dev machines from the Android emulator","Prefer https:// endpoints so iOS ATS never blocks the request","Read the embedded URL/method/body-size in the message - it pinpoints the failing request"],"tags":["react-native","network","http","fetch","sync","offline"],"backgroundTag":"network-request-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"}