Skip to content

[Feature]: Native AWS Lambda Powertools for TypeScript integration #470

@abhishekc-timedotmoney

Description

@abhishekc-timedotmoney

Feature Request

Native integration with AWS Lambda Powertools for TypeScript Logger, similar to how the Python Durable SDK supports Powertools.

Problem

When using Powertools Logger as a customLogger via context.configureLogger(), the logs get double-wrapped in CloudWatch because:

  1. Durable functions require LogFormat: JSON in the Lambda config
  2. Lambda's LogFormat: JSON patches the global console object to wrap output in {"timestamp", "level", "requestId", "message"}
  3. Powertools Logger uses the global console.info() to output its own structured JSON
  4. Lambda catches that and stringifies Powertools' JSON into the message field

Result — double-wrapped JSON:

{
  "timestamp": "2026-03-09T13:52:31.481Z",
  "level": "INFO",
  "requestId": "fa3b7f07-0be3-4380-9a53-fb080779fcf4",
  "message": "{\n    \"level\": \"INFO\",\n    \"message\": \"workflow-started\",\n    \"timestamp\": \"2026-03-09T19:22:31.039+05:30\",\n    \"service\": \"lambda-user-account-deletion\",\n    \"sampling_rate\": 0,\n    \"xray_trace_id\": \"1-69aed09e-5a04f2fc1f7bee1748385655\",\n    \"tm_user_id\": \"0199c820-c4bd-778a-9197-580108aea912\"\n}"
}

Workaround

Override the Powertools Logger's internal console with a direct process.stdout writer (same technique the Durable SDK's own DefaultLogger uses and Powertools itself uses):

import { Console } from 'node:console';
import { Logger } from '@aws-lambda-powertools/logger';

const logger = new Logger({ serviceName: 'my-service' });

// Bypass Lambda's LogFormat:JSON console patching to prevent double-wrapped JSON logs
(logger as unknown as { console: Console }).console = new Console({
  stdout: process.stdout,
  stderr: process.stderr,
});

export { logger };

Then pass it as customLogger:

const handler = async (event: MyEvent, context: DurableContext<Logger>) => {
  context.configureLogger({ customLogger: logger });
  context.logger.info({ message: 'workflow-started' });
};

export const myFunction = withDurableExecution(handler);

Result — clean Powertools output:

{
    "level": "INFO",
    "message": "workflow-started",
    "timestamp": "2026-03-09T19:37:51.268+05:30",
    "service": "my-service",
    "sampling_rate": 0,
    "xray_trace_id": "1-69aed434-506caa866976504e1a0ec55f"
}

Requested Feature

  1. First-class Powertools integration — The Python Durable SDK has native Powertools support where context.configure_logger(powertools_logger) automatically injects durable execution metadata (executionArn, operationId, attempt, requestId) into every Powertools log entry via append_keys(). The JS SDK should have parity.

  2. Handle the console patching conflict — When Powertools is detected as the customLogger, the SDK should automatically handle the LogFormat: JSON console patching conflict so users don't need the workaround above.

  3. Inject durable metadata into Powertools structured logs — Use Powertools' appendKeys() method to inject durable execution context (like executionArn, operationId) into every log entry automatically, rather than just delegating log calls.

Environment

  • SDK Version: latest
  • Node.js: 24.x
  • Powertools: @aws-lambda-powertools/logger v2
  • Runtime: Durable Function (nodejs:24.DurableFunction.v10)

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions