Debugging - TypeScript SDK feature guide
The Debugging section of the Temporal TypeScript SDK developer's guide covers tools for debugging and how to troubleshoot common issues.
How to debug in a development environment
In addition to the normal development tools of logging and a debugger, you can also see what’s happening in your Workflow by using the Web UI or Temporal CLI.
How to debug in a production environment
You can debug production Workflows using:
You can debug and tune Worker performance with metrics and the Worker performance guide. For information on setting up SDK metrics, see Metrics in the Observability section of the TypeScript SDK developer's guide.
Debug Server performance with Cloud metrics or self-hosted Server metrics.
How to troubleshoot common issues in the TypeScript SDK
Two locations to watch
- Workflow Errors are reflected in Temporal Web.
- Worker errors and logs are reflected in the terminal.
If something isn't behaving the way you expect, make sure to check both locations for helpful error messages.
Stale Workflows
If you are developing Workflows and finding that code isn't executing as expected, the first place to look is whether old Workflows are still running.
If those old Workflows have the same name and are on the same task queue, Temporal will try to continue executing them on your new code by design. You may get errors that make no sense to you because
- Temporal is trying to execute old Workflow code that no longer exists in your codebase, or
- your new Client code is expecting Temporal to execute old Workflow/Activity code it doesn't yet know about.
The biggest sign that this is happening is if you notice Temporal is acting non-deterministically: running the same Workflow twice gets different results.
Stale workflows are usually a non-issue because the errors generated are just noise from code you no longer want to run. If you need to terminate old stale Workflows, you can do so with Temporal Web or the Temporal CLI.
Workflow/Activity registration errors
If your Workflows or Activities are not imported or spelled correctly, here are some errors we've seen:
ApplicationFailure: 'MyFunction' is not a function
Workflow did not register a handler for MyQuery
Double check that your Workers are registering the right Workflow and Activity Definitions (function names) on the right Task Queues.
If you are running Temporal in a monorepo, then your node_modules
may be in a different location than where Temporal expects to find it by default, which results in errors like:
[ERROR] Module not found: Error: Can't resolve '@temporalio/workflow/lib/worker-interface.js' in '/src'
Our Next.js tutorial is written for people setting up Temporal within an existing monorepo, which may be of use here.
When you pass a workflowsPath
, our Webpack config expects to find node_modules
in the same or a parent/ancestor directory.
If you are custom bundling your own Workflows you may get errors like these:
[ERROR] Failed to activate workflow {
runId: 'aaf84a83-51ce-462a-9ab7-6a641a703bff',
error: ReferenceError: exports is not defined,
workflowExists: false
}
Temporal Workflow Bundles need to export a set of methods that fit the compiled worker-interface.ts
from @temporalio/workflow
as an entry point.
We do offer a bundleWorkflowCode
method to assist you with this, though it uses our Webpack settings.
For more information, see the Register types section.