The short answer
This error indicates that a native HubSpot custom code action reached its execution time limit. Measure where the time is spent before changing the architecture. Reduce unnecessary work where possible; if the job needs a longer runtime, choose an execution service with explicit limits and a reliable return path.
Confirm the failure
Open the failed execution and read the error, elapsed time and available logs. A timeout tells you the action did not finish in time; it does not prove the logic is correct. A loop, an unexpectedly large input or an external request without a timeout can all be involved.
HubSpot documents 20 seconds of execution and 128 MB of memory for native custom code actions. These are different constraints: investigate memory failures separately rather than treating every failed run as a timeout.
Measure one section at a time
Put timing around an existing operation. This is an instrumentation pattern, not a complete handler; replace existingOperation with the operation you are investigating.
const started = Date.now();
try {
await existingOperation();
} finally {
console.log("lookup elapsed ms", Date.now() - started);
}
Record durations and a non-sensitive operation name, not full request bodies or credentials. Compare several representative inputs, including records with many associations. One fast test is not evidence that the largest enrollment will fit.
Reduce the work before moving it
- Map properties into the action instead of fetching values already available to the workflow.
- Fetch only needed fields and pages. Put a bound on pagination.
- Use bounded concurrency for independent requests when the API permits it.
- Give each external request a timeout that leaves time to handle failure.
- Split independent per-record work when the workflow can preserve the intended behavior.
Do not use an unawaited request as a reliable background-job mechanism. If work must continue after the action responds, use a service designed to own that job and track its completion.
When a longer-running action is appropriate
Document generation or a slow external calculation may remain too large after those changes. A connected-app action can move execution to another runtime, but you still need to check its timeout, memory budget and how results reach subsequent workflow steps.
Turbyn provides that code-running step, not unlimited compute. Compare the current plan allowances, the action’s configured timeout and your dependency’s limits. Plan for a failed or missing result as well as the happy path.
Make a replay safe
Before testing again, list every side effect: property writes, document uploads, messages and payments. Use a stable idempotency key where the destination supports it, or check for an existing result before creating another one.
Turbyn test runs use sample input, but outgoing requests still happen. Guard production writes with ctx.mode. For a successful run with an empty downstream value, investigate output mapping instead of extending the timeout.
Sources and references
Source documentation checked for this update. Availability can vary by subscription and account.