{"record":{"id":"494fd2dbc43e65b9","repo":"alyssaxuu/screenity","slug":"uploader-not-initialized","errorCode":null,"errorMessage":"Uploader not initialized","messagePattern":"Uploader not initialized","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/pages/CloudRecorder/bunnyTusUploader.js","lineNumber":1273,"sourceCode":"      );\n    } else {\n      this.debugLog(\"Skipping save-upload-meta because user token is missing\", {\n        mediaId: this.mediaId,\n        uploadUrl: this.uploadUrl,\n        signature: this.signature,\n        expires: this.expires,\n      });\n    }\n  }\n\n  async write(chunk) {\n    if (this.isFinalizing) {\n      this.bytesLostAfterFinalize += chunk?.size || 0;\n      this.setUploaderError(\"write-after-finalize\");\n      throw new Error(\"Cannot write during finalization\");\n    }\n    if (this.isPaused) throw new Error(\"Uploader paused\");\n    if (!this.uploadUrl) throw new Error(\"Uploader not initialized\");\n\n    if (this.status === \"error\") {\n      throw new Error(`Uploader in error state: ${this.error}`);\n    }\n\n    await this.checkAuthExpiration();\n    this.status = \"uploading\";\n    if (!this.hasEmittedClientStarted) {\n      this.hasEmittedClientStarted = true;\n      this.emitTelemetry(\"upload_client_started\");\n    }\n\n    for (let i = 0; i < chunk.size; i += this.CHUNK_SIZE) {\n      const subChunk = chunk.slice(i, i + this.CHUNK_SIZE);\n      this.chunkQueue.push(subChunk);\n      this.queuedBytes += subChunk.size;\n      this.totalBytes += subChunk.size;\n    }","sourceCodeStart":1255,"sourceCodeEnd":1291,"githubUrl":"https://github.com/alyssaxuu/screenity/blob/512606387b8d07dda5e63bb428bd063f0a2a3ed0/src/pages/CloudRecorder/bunnyTusUploader.js#L1255-L1291","documentation":"Guard in BunnyTusUploader.write(): this.uploadUrl is falsy, meaning no tus upload session was created/initialized (create() never ran or failed), so chunks cannot be PATCHed anywhere. The uploader is being used before successful initialization.","triggerScenarios":"Calling write() before awaiting the create/init step, or after session creation failed with 'Failed to start TUS upload session', leaving uploadUrl null.","commonSituations":"Caller forgetting to await uploader.init()/create before streaming chunks; init promise rejected but the caller continued; reusing a fresh uploader instance after a previous failure.","solutions":["Ensure create()/init completes successfully before calling write()","Check the earlier initialization error logs for why uploadUrl was never set","Reset/recreate the uploader instance instead of reusing a failed one"],"exampleFix":"// before\nuploader.startRecordingFlow();\nawait uploader.write(chunk);\n// after\nawait uploader.init();\nif (!uploader.uploadUrl) throw new Error(\"TUS init failed; cannot write\");\nawait uploader.write(chunk);","handlingStrategy":"validation","validationCode":"if (!uploader.uploadUrl) {\n  throw new Error(\"call init() and wait for a TUS session before writing\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  await uploader.write(chunk);\n} catch (e) {\n  if (e.message === \"Uploader not initialized\") {\n    await uploader.init();\n    await uploader.write(chunk); // retry once after init\n  }\n}","preventionTips":["Await session creation before starting the chunk pipeline","Gate the write loop on successful init","Handle init rejections so the flow cannot proceed on failure"],"tags":["upload","tus","lifecycle","initialization"],"backgroundTag":"upload-not-initialized","analyzedSha":"512606387b8d07dda5e63bb428bd063f0a2a3ed0","analyzedAt":"2026-09-02T20:59:09.419Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}