{"record":{"id":"30cafb5aabb996f5","repo":"transloadit/uppy","slug":"network","errorCode":"NETWORK","errorMessage":"Network error during S3 request","messagePattern":"Network error during S3 request","errorType":"error_code","errorClass":"S3NetworkError","httpStatus":null,"severity":"error","filePath":"packages/@uppy/aws-s3/src/s3-client/S3mini.ts","lineNumber":331,"sourceCode":"        url,\n        method: request.method,\n        data,\n        onProgress,\n        signal,\n        contentType,\n      })\n\n      return { xhr, url }\n    } catch (err: unknown) {\n      // NetworkError or errors with attached XHR (from onAfterResponse throws)\n      if (\n        err instanceof Error &&\n        'request' in err &&\n        err.request instanceof XMLHttpRequest\n      ) {\n        const xhr = err.request as XMLHttpRequest\n        if (xhr.status === 0) {\n          throw new U.S3NetworkError(\n            'Network error during S3 request',\n            'NETWORK',\n            err,\n          )\n        }\n        // HTTP errors (non-2xx responses from NetworkError)\n        const parsedBody = this._parseErrorXml(\n          (name: string) => xhr.getResponseHeader(name),\n          xhr.responseText,\n        )\n        const serviceCode =\n          xhr.getResponseHeader('x-amz-error-code') ?? parsedBody.svcCode\n\n        // If expired token error and using getCredentials, clear cache and retry once\n        if (\n          shouldRetryCredentials &&\n          this.getCredentials != null &&\n          serviceCode != null &&","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/transloadit/uppy/blob/5d4dedd02a1ac0ae022c75c54aca76558f88e256/packages/@uppy/aws-s3/src/s3-client/S3mini.ts#L313-L349","documentation":"When the underlying XHR fails at the network layer, s3mini inspects the error's request: if `xhr.status === 0` (request never completed — no HTTP response), it wraps the failure in S3NetworkError with code 'NETWORK'. This distinguishes connectivity/DNS/CORS-blocked requests from actual HTTP error responses (non-2xx) which are handled separately.","triggerScenarios":"Device offline or connection dropped mid-request; DNS failure for the endpoint; CORS preflight blocked (browser reports status 0); TLS certificate errors; proxy/firewall resetting the connection. Any XHR that terminates without an HTTP status.","commonSituations":"Browser uploads blocked by missing/incorrect CORS config on the bucket (preflight failure shows as status 0); flaky mobile networks during multipart uploads; corporate proxies blocking S3 domains; wrong endpoint hostname that doesn't resolve; mixed-content (https page → http endpoint).","solutions":["Open devtools Network tab: a failed OPTIONS preflight points to CORS config; a failed DNS/connect points to the endpoint/offline.","For CORS, ensure the bucket allows your origin, the methods (PUT/POST/GET), and required headers (content-type, x-amz-*).","Verify the endpoint URL is reachable from the client environment (curl the URL, check TLS/mixed content).","Retry with backoff for transient network drops — S3NetworkError is safe to retry, especially idempotent part uploads."],"exampleFix":"// before\ntry { await s3.uploadPart(...) } catch (e) { throw e }\n// after\ntry { await s3.uploadPart(...) } catch (e) {\n  if (e.code === 'NETWORK') await retryWithBackoff(() => s3.uploadPart(...))\n  else throw e\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":"const isNetworkError = (e: unknown): e is { code: 'NETWORK' } =>\n  typeof e === 'object' && e !== null && (e as any).code === 'NETWORK'","tryCatchPattern":"async function uploadWithRetry(fn: () => Promise<unknown>, tries = 3) {\n  for (let i = 0; i < tries; i++) {\n    try { return await fn() } catch (e) {\n      if ((e as any)?.code === 'NETWORK' && i < tries - 1) {\n        await new Promise((r) => setTimeout(r, 2 ** i * 500)); continue\n      }\n      throw e\n    }\n  }\n}","preventionTips":["Verify bucket CORS (origin, methods, x-amz-* headers) before shipping browser uploads.","Retry network-coded errors with exponential backoff; part uploads are idempotent.","Ensure the endpoint is HTTPS when the page is HTTPS to avoid mixed-content failures."],"tags":["aws-s3","network","xhr","cors","offline"],"backgroundTag":"network-request-failed","analyzedSha":"5d4dedd02a1ac0ae022c75c54aca76558f88e256","analyzedAt":"2026-08-28T12:18:41.267Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}