@shinyaz

Lambda Durable Functions SDK DurableContext cannot be named-imported in .mjs

1 min read

The official TypeScript sample shows import { withDurableExecution, DurableContext }, so I used it as-is. Lambda threw this at runtime:

Output
SyntaxError: The requested module '@aws/durable-execution-sdk-js'
does not provide an export named 'DurableContext'

DurableContext is a TypeScript type-only export — it has no runtime representation in the ESM module. When deploying .mjs files directly, only import withDurableExecution:

JavaScript (.mjs)
import { withDurableExecution } from "@aws/durable-execution-sdk-js";
 
export const handler = withDurableExecution(
  async (event, context) => {
    // context is automatically DurableContext
    await context.step("my-step", async () => { /* ... */ });
  }
);

If you're building with TypeScript, use import type { DurableContext } for type checking. This only bites you when deploying raw .mjs to Lambda.

Share this post

Shinya Tahara

Shinya Tahara

Solutions Architect @ AWS

I'm a Solutions Architect at AWS, providing technical guidance primarily to financial industry customers. I share learnings about cloud architecture and AI/ML on this site.The views and opinions expressed on this site are my own and do not represent the official positions of my employer.