tonhowtf/omniget · warning

[sc-download-store] listen single failed

Error message

[sc-download-store] listen single failed

What it means

Logged in download-store.start() when registering the Tauri event listener for `study-soundcloud-download-progress` via listen() fails. Without this listener, single-download progress events are never received, so per-track progress UI silently stalls. Non-fatal warning; the store keeps running.

Solutions

  1. Check the logged err for the listen() failure reason.
  2. Only call start() inside the Tauri webview (guard on window.__TAURI__ availability).
  3. Ensure `study-soundcloud-download-progress` events are emitted with a matching event name from Rust.
  4. Retry listener registration with a small backoff; transient failures can occur at startup.
  5. Add a fallback UI state (e.g. 'progress unavailable') when listeners fail so the UI doesn't stall silently.

Example fix

// before
} catch (err) {
  console.warn("[sc-download-store] listen single failed", err);
}
// after
} catch (err) {
  console.warn("[sc-download-store] listen single failed", err);
  this.progressAvailable = false;
  scheduleRetry(() => this.start()); // re-register listeners after transient failure
}
Defensive patterns

Strategy: retry

Validate before calling

if (!isTauri()) return; // listen() is unavailable outside the Tauri webview

Type guard

function isTauri(): boolean {
  return typeof window !== "undefined" && "__TAURI_INTERNALS__" in window;
}

Try / catch

try {
  const single = await listen<SinglePayload>("study-soundcloud-download-progress", (e) => this.handleSingle(e.payload));
  this.listeners.push(single);
} catch (err) {
  console.warn("[sc-download-store] listen single failed", err);
  scheduleRetry(() => this.start());
}

Prevention

When it happens

Trigger: Calling start() when listen("study-soundcloud-download-progress") rejects: webview event API unavailable (browser dev), app window closing, or Tauri event system error.

Common situations: Running the app in a plain browser where Tauri listen() is unavailable; calling start() during teardown; duplicated event names / plugin registration problems.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/f5bea0917edca140. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/study-music/download-store.svelte.ts:96

  drawerOpen = $state(false);

  private pendingByTrackId = new Map<number, string>();
  private listeners: UnlistenFn[] = [];
  private nonce = 0;
  private started = false;

  start() {
    if (this.started) return;
    this.started = true;
    void (async () => {
      try {
        const single = await listen<SinglePayload>(
          "study-soundcloud-download-progress",
          (e) => this.handleSingle(e.payload),
        );
        this.listeners.push(single);
      } catch (err) {
        console.warn("[sc-download-store] listen single failed", err);
      }
      try {
        const bulk = await listen<BulkPayload>(
          "study-soundcloud-download-bulk-progress",
          (e) => this.handleBulk(e.payload),
        );
        this.listeners.push(bulk);
      } catch (err) {
        console.warn("[sc-download-store] listen bulk failed", err);
      }
    })();
  }

  stop() {
    for (const u of this.listeners) {
      try {
        u();
      } catch {

View on GitHub (pinned to 8600b91f42)