generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 181
Open
Labels
confirmedThe scope is clear, ready for implementationThe scope is clear, ready for implementationfeature-requestThis item refers to a feature request for an existing or new utilityThis item refers to a feature request for an existing or new utility
Description
Expected Behavior
I am able to use Powertools class decorators with Durable Function handlers
Current Behavior
Typescript emits a warning, as the Handler interface does not accept the DurableContext type.
The decorators break, as they try to access properties on the Lambda Context, but these must be accessed with a different path in the DurableContext type.
Code snippet
import {
withDurableExecution,
type DurableContext,
} from "@aws/durable-execution-sdk-js";
import { Logger, LogLevel } from "@aws-lambda-powertools/logger";
import { LambdaInterface } from "@aws-lambda-powertools/commons/types";
const logger = new Logger({
serviceName: "test-suite-validation",
logLevel: LogLevel.TRACE,
});
class Lambda implements LambdaInterface {
// Decorate your handler class method
@logger.injectLambdaContext()
public async handler(
_event: unknown,
_context: DurableContext
): Promise<void> {
logger.info("This is an INFO log with some context");
}
}
const myFunction = new Lambda();
export const handler = withDurableExecution(
myFunction.handler.bind(myFunction)
);Steps to Reproduce
- Create a lambda function with a durable config specified, and the handler above
- Invoke the function
- Observe an error is raised
Possible Solution
Update the Handler type in aws-lambda to accept a LambdaContext or a Durable Context
or
Create a new DurableHandler type?
Update decorators to correctly access the Lambda Context when passed a Durable Context
Powertools for AWS Lambda (TypeScript) version
latest
AWS Lambda function runtime
24.x
Packaging format used
npm
Execution logs
Metadata
Metadata
Assignees
Labels
confirmedThe scope is clear, ready for implementationThe scope is clear, ready for implementationfeature-requestThis item refers to a feature request for an existing or new utilityThis item refers to a feature request for an existing or new utility
Type
Projects
Status
Working on it