Skip to content

bug(core): onCapture callback errors in capture.ts are silently swallowed #276

Closed

Description

@vamgan

Summary

In packages/core/src/capture.ts, the onCapture callback is invoked after a capture completes. If the callback throws (or returns a rejected promise in an async case), the error is silently lost — no console warning, no re-throw, no way for the caller to detect the failure.

Root cause

The capture handler invokes options.onCapture(packet, selection) without wrapping it in a try/catch, and without awaiting the return value if the callback is async.

Impact

  • Silent data loss: if onCapture is async and fails (e.g. a network POST fails), the user's capture attempt appears to succeed
  • No way to surface errors to the UI for a retry or error state

Fix

Wrap the call and surface errors through a documented onError channel:

try {
  await options.onCapture?.(packet, selection);
} catch (err) {
  options.onError?.(err instanceof Error ? err : new Error(String(err)));
}

onError should be added to the capture options type to give callers a standard error handler.

Activity

  1. added
    bugSomething isn't working
    area: coreCore package and cross-package runtime behavior
    on Jun 1, 2026
  2. added a commit that references this issue on Jun 1, 2026
    0d77701
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreCore package and cross-package runtime behaviorbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions