Is it possible to intercept Workflow exceptions and send them to Sentry?

Workflow Interceptors are executed inside the Workflow sandbox, and therefore need to play with the same constraints as Workflow code regarding not importing non-deterministic code (see related doc page).

@sentry/node is obviously a non-deterministic module, as it is performing network access, reading configuration files, starting child process, etc.

As a general rule, non-deterministic code should be moved to activities or local activities. However, the TS SDK also provide a different mechanism, sinks, that is better suited for logging, observability and similar use cases.

Sinks are similar to Activities in that they are both registered on the Worker and proxied into the Workflow. However, they differ from Activities in important ways:

  • Sink functions don’t return any value back to the Workflow and cannot not be awaited.
  • Sink calls are not recorded in Workflow histories (no timeouts or retries).
  • Sink functions are always run on the same Worker that runs the Workflow they are called from.

See this related subsection in our documentation.