Open dmost714 opened 2 years ago
Hey @dmost714 :wave: thanks for taking the time to raise this! I've gone ahead and marked this as a feature request to improve the function mock capability to use the runtime version specified in the function's CloudFormation template, and have also added a docs label to update our docs to reflect this current limitation 🙂
Also facing this issue, and it does make development workflow way more complicated than it has to be. Support for using system node version would be crucial, especially considering that Node 14 is also about to reach EOL.
Makes me wonder, doesn't other people use local Mocking, or how this issue hasn't gotten more traction? What sort of development workflows do people use with Node lambdas?
Hey, apparently mocking now always uses Node 18? @josefaidt
Hey, apparently mocking now always uses Node 18? @josefaidt
Confirmed. Ran a mock. It was the old node. Upgraded to Amplify cli v12.0.3, ran mock, and it's using v18.15.0. My local node is 18.12.1.
I edited the lambda's cloudformation-template.json file to downgrade the lambda to v16 and ran mock. Mock used v18 anyway. I suppose people on an old node can/should upgrade. Perhaps print a warning when versions mismatch. People will use APIs from and test against v18, then deploy/run v16. Nothing fun comes from that.
Thrilled I can mock Lambdas with Amplify environment context again!
Hey, apparently mocking now always uses Node 18? @josefaidt
Confirmed. Ran a mock. It was the old node. Upgraded to Amplify cli v12.0.3, ran mock, and it's using v18.15.0. My local node is 18.12.1.
I edited the lambda's cloudformation-template.json file to downgrade the lambda to v16 and ran mock. Mock used v18 anyway. I suppose people on an old node can/should upgrade. Perhaps print a warning when versions mismatch. People will use APIs from and test against v18, then deploy/run v16. Nothing fun comes from that.
Thrilled I can mock Lambdas with Amplify environment context again!
I am using amplify cli v12.1.1 and when I mock a function it uses node 14. I am using node canvas which has binaries built specifically for the given node version, so this unexpected node version is making mocking useless in my use case.
Before opening, please confirm:
How did you install the Amplify CLI?
npm
If applicable, what version of Node.js are you using?
v16.16.0
Amplify CLI Version
9.2.1
What operating system are you using?
Mac
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
Yes. Notably, I added/updated LambdaFunction properties:
Amplify Categories
function
Amplify Commands
Not applicable
Describe the bug
When I mock functions, they're using NodeJS v14.18.1. From what I can tell, I don't even have that version installed.
amplify mock function myAppMylambda --event src/event.json
Verified by console logging the node version within the Lambda:
Expected behavior
amplify mock function should use the runtime described in the function's cloudformation template. Or perhaps use the 'default' version of NodeJS, perhaps with a warning that the local node may be different than the one the Lambda will run in the cloud.
Reproduction steps
amplify mock function
GraphQL schema(s)
No response
Project Identifier
No response
Log output
Additional information
@josefaidt on Discord
(Looks like
amplify mock
is missing from the amplify commands drop down.)Thanks!