tauri-apps/tauri · warning

[TAURI] Couldn't find callback id

Error message

[TAURI] Couldn't find callback id ${id}. This might happen when the app is reloaded while Rust is running an asynchronous operation.

What it means

Tauri's core JavaScript dispatches Rust-issued callbacks via runCallback(id, data) by looking up the id in the local callbacks map. If the id was never registered or was removed (e.g. because the page reloaded), it logs this warning instead of invoking anything. Data from the Rust side is silently dropped for that callback.

Solutions

  1. Avoid reloading the webview while Rust async commands are pending; await or cancel in-flight commands first.
  2. Re-register callbacks/channels after any reload and make Rust re-send using the new IDs.
  3. Treat this as non-fatal: re-issue the operation after reload rather than relying on the stale callback result.
  4. In dev, disable HMR full reloads for pages that launch long-running Rust tasks.
Defensive patterns

Strategy: fallback

Validate before calling

function ensureCallback(id) {
  if (!window.__TAURI_INTERNALS__.callbacks.has(id)) {
    console.warn('callback', id, 'missing — re-registering before invoking Rust command')
    return false
  }
  return true
}

Prevention

When it happens

Trigger: Rust completes an asynchronous operation and emits a callback id that no longer exists in the webview's callbacks map — typically after window.location.reload() or SPA full reload, or invoking a callback id that was never registered via transformCallback/registerCallback.

Common situations: Hot-module reload or dev-server auto refresh while a Rust async command is in flight, app reload during a long-running async task, or plugin code holding stale channel/callback IDs across a reload.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of tauri-apps/tauri@460ec35447 (2026-09-18). Data as JSON: /api/errors/0fc4a3c2736d3a86. Report an issue: GitHub.

Appendix: source

Thrown at crates/tauri/scripts/core.js:44

    callbacks.set(identifier, (data) => {
      if (once) {
        unregisterCallback(identifier)
      }
      return callback && callback(data)
    })
    return identifier
  }

  function unregisterCallback(id) {
    callbacks.delete(id)
  }

  function runCallback(id, data) {
    const callback = callbacks.get(id)
    if (callback) {
      callback(data)
    } else {
      console.warn(
        `[TAURI] Couldn't find callback id ${id}. This might happen when the app is reloaded while Rust is running an asynchronous operation.`
      )
    }
  }

  // Maybe let's rename it to `registerCallback`?
  Object.defineProperty(window.__TAURI_INTERNALS__, 'transformCallback', {
    value: registerCallback
  })

  Object.defineProperty(window.__TAURI_INTERNALS__, 'unregisterCallback', {
    value: unregisterCallback
  })

  Object.defineProperty(window.__TAURI_INTERNALS__, 'runCallback', {
    value: runCallback
  })

View on GitHub (pinned to 460ec35447)