castleadmin / nx-plugins

Monorepo for nx plugin development
MIT License
2 stars 0 forks source link

I can see this issue when invoking lambda function locally. Invalid time zone specified #10

Closed blkdot closed 2 months ago

blkdot commented 3 months ago

{"errorType": "RangeError", "errorMessage": "Invalid time zone specified: :/etc/localtime", "trace": ["RangeError: Invalid time zone specified: :/etc/localtime", " at new DateTimeFormat ()", " at #getDateFormatter (file:///var/task/index.mjs:1101:12)", " at #generateISOTimestampWithOffset (file:///var/task/index.mjs:1119:78)", " at PowertoolsLogFormatter.formatTimestamp (file:///var/task/index.mjs:1070:50)", " at PowertoolsLogFormatter.formatAttributes (file:///var/task/index.mjs:1185:23)", " at _Logger.createAndPopulateLogItem (file:///var/task/index.mjs:1790:35)", " at _Logger.processLogItem (file:///var/task/index.mjs:1891:38)", " at _Logger.info (file:///var/task/index.mjs:1458:10)", " at Runtime.exampleHandler [as handler] (file:///var/task/index.mjs:2080:10)", " at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1173:29)"]}

castleadmin commented 3 months ago

Hi @blkdot , thank you for reporting this issue.

I wasn't able to reproduce the issue on my side. I will provide some background knowledge about the inner workings. Hopefully, this will be enough to resolve the issue 🙏.

nx-serverless-cdk is just a slim glue of existing AWS tools. For the local execution of the Lambda function, AWS SAM is used. AWS SAM relies only on

for local execution. Both can be found in the cdk.out directory after the cdk synth command has been executed.

The error you have posted seems to originate from the AWS Powertools library. This is an optional library. To exclude other error sources, I recommend throwing it out of the Lambda Source Code, generating a new cdk.out output, and testing the local execution again.

If the execution is successful, the next step would be to look into the synthesizing of the cdk.out directory. The following happens during the execution of the cdk synth command.

The NodejsFunction Construct is responsible to kick of the esbuild process. The esbuild process can be started locally (default) or in a Docker Container.

As the next test, I would recommend trying out the esbuild Docker process. If the Docker build and the local Lambda function execution succeeds then the issue is most likely related to the local UNIX setup.

To enable the Docker build, please at the following line to the default-lambda-props.ts file.

bundling: {
    ...
    forceDockerBundling: true
},

Please also check if you're using

blkdot commented 3 months ago

Got it. thanks for your kind explanation.