Interceptor for activity function execution on the activity worker side. Runs inside the activity's activityAsyncLocalStorage context, wrapping the actual activity function invocation — not the proxy call in the workflow.

Unlike workflow-side interceptors, this runs where the activity actually executes. Use it for cross-cutting concerns like logging, metrics, auth validation, or error enrichment at the point where the activity actually executes.

Durable.registerActivityInboundInterceptor({
async execute(activityName, args, next) {
console.log(`Activity ${activityName} starting with`, args);
const start = Date.now();
try {
const result = await next();
console.log(`Activity ${activityName} completed in ${Date.now() - start}ms`);
return result;
} catch (err) {
console.error(`Activity ${activityName} failed`, err);
throw err;
}
}
});
interface ActivityInboundCallsInterceptor {
    execute(activityName: string, args: any[], next: (() => Promise<any>)): Promise<any>;
}

Methods

Methods

  • Called around the actual activity function execution on the worker.

    Parameters

    • activityName: string

      The name of the activity being executed

    • args: any[]

      The arguments passed to the activity

    • next: (() => Promise<any>)

      Call to execute the next interceptor or the activity itself

        • (): Promise<any>
        • Returns Promise<any>

    Returns Promise<any>

    The activity function's return value