aws-lambda-nodejs: Default entry finding fails when defining file starts with "file://"
See original GitHub issueDescribe the bug
Attempting to create a lambda with NodejsFunction, which should auto find the handler based on the defining files path.
I get an error that looks like this:
Error: Cannot find handler file file:///Users/stack.handler.ts, file:///Users/<path>/stack.handler.js or file:///Users/<path>/stack.handler.mjs
where the middle of the path has been replaced with <path> for brevity and privacy.
This implies the paths being checked start with “file://”, which I’ve tested and does not work with Node 16.13.1.
Those paths are produced from this function, which I believe is incorrect.
This is running on macos 12.5, with the a fore mentioned version of nodejs.
Expected Behavior
I expected it to find the file, as the path was correct without the file://
prefix.
Current Behavior
Error: Cannot find handler file file:///Users/stack.handler.ts, file:///Users/<path>/stack.handler.js or file:///Users/<path>/stack.handler.mjs
Reproduction Steps
Create a lambda function using NodejsFunction
with no entry
parameter specified, and synthesize.
Possible Solution
callsites()
produces paths that start with file:// when they are local files, and findDefiningFile
doesn’t scrub the path. Maybe make findDefining file remove the prefix when it’s file://
Additional Information/Context
No response
CDK CLI Version
2.37.1 (build f15dee0)
Framework Version
No response
Node.js Version
16.13.1
OS
macos 12.5
Language
Typescript
Language Version
4.7.2
Other information
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:7 (2 by maintainers)
Thanks @okko, appreciate you stepping in with the reproduction.
Workaround until issue is resolved in aws-cdk: