alyssaxuu/screenity · error · Error

Uploader not initialized

Error message

Uploader not initialized

What it means

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.

Source

Thrown at src/pages/CloudRecorder/bunnyTusUploader.js:1273

      );
    } else {
      this.debugLog("Skipping save-upload-meta because user token is missing", {
        mediaId: this.mediaId,
        uploadUrl: this.uploadUrl,
        signature: this.signature,
        expires: this.expires,
      });
    }
  }

  async write(chunk) {
    if (this.isFinalizing) {
      this.bytesLostAfterFinalize += chunk?.size || 0;
      this.setUploaderError("write-after-finalize");
      throw new Error("Cannot write during finalization");
    }
    if (this.isPaused) throw new Error("Uploader paused");
    if (!this.uploadUrl) throw new Error("Uploader not initialized");

    if (this.status === "error") {
      throw new Error(`Uploader in error state: ${this.error}`);
    }

    await this.checkAuthExpiration();
    this.status = "uploading";
    if (!this.hasEmittedClientStarted) {
      this.hasEmittedClientStarted = true;
      this.emitTelemetry("upload_client_started");
    }

    for (let i = 0; i < chunk.size; i += this.CHUNK_SIZE) {
      const subChunk = chunk.slice(i, i + this.CHUNK_SIZE);
      this.chunkQueue.push(subChunk);
      this.queuedBytes += subChunk.size;
      this.totalBytes += subChunk.size;
    }

View on GitHub (pinned to 512606387b)

Solutions

  1. Ensure create()/init completes successfully before calling write()
  2. Check the earlier initialization error logs for why uploadUrl was never set
  3. Reset/recreate the uploader instance instead of reusing a failed one

Example fix

// before
uploader.startRecordingFlow();
await uploader.write(chunk);
// after
await uploader.init();
if (!uploader.uploadUrl) throw new Error("TUS init failed; cannot write");
await uploader.write(chunk);
Defensive patterns

Strategy: validation

Validate before calling

if (!uploader.uploadUrl) {
  throw new Error("call init() and wait for a TUS session before writing");
}

Try / catch

try {
  await uploader.write(chunk);
} catch (e) {
  if (e.message === "Uploader not initialized") {
    await uploader.init();
    await uploader.write(chunk); // retry once after init
  }
}

Prevention

When it happens

Trigger: Calling write() before awaiting the create/init step, or after session creation failed with 'Failed to start TUS upload session', leaving uploadUrl null.

Common situations: 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.

Related errors


AI-assisted analysis of alyssaxuu/screenity@512606387b (2026-09-02). Data as JSON: /api/errors/494fd2dbc43e65b9. Report an issue: GitHub.