What do you mean by manual deployment? Drag and drop? Netlify CLI?
I deployed the repository using Netlify CLI (which shows as a manual deploy in the dashboard) and the hello-world endpoint works fine. (I haven’t tested the mail function as I don’t have a SendGrid API key handy.)
Functions will only work when deployed via git or CLI.
ntl deploy --prod
Deploy path: /Users/jamessherry/sites/netlify-fns-2022-demo2/public
Functions path: /Users/jamessherry/sites/netlify-fns-2022-demo2/netlify/functions
Configuration path: /Users/jamessherry/sites/netlify-fns-2022-demo2/netlify.toml
Deploying to main site URL...
✔ Finished hashing 5 files and 1 functions
✔ CDN requesting 1 files and 0 functions
✔ Finished uploading 1 assets
✔ Deploy is live!
Logs: https://app.netlify.com/sites/ghjk/deploys/630e9363a51b21119629feb4
Unique Deploy URL: https://630e9363a51b21119629feb4--ghjk.netlify.app
Website URL: https://ghjk.netlify.app
Deploy log:
11:47:00 PM: Creating deploy upload records
11:47:01 PM: Starting post processing
11:47:01 PM: Post processing - HTML
11:47:01 PM: Post processing - header rules
11:47:01 PM: Post processing - redirect rules
11:47:01 PM: Post processing done
11:47:05 PM: Site is live ✨
This shows that no functions were uploaded, meaning there is no difference between what was previously build and what was built in this deploy. You can add --skip-functions-cache to ensure they are rebuilt so ntl deploy --prod --skip-functions-cache
I ran through the same steps again and everything worked.
You didn’t test the hello-world endpoint locally (though I assume it would work as the other function worked too.)
It is curious the .netlify/state.json was not created when you ran ntl sites:create --name <name>. When I do this, the final output line tells me the site is linked which is (it appears) not the case for you, which is why you needed to manually link it. The reason for this I don’t know.
I run a school (https://www.thejump.tech/) that trains new developers. I advocate using netlify a lot and I really want them to be able to use the lambda capability on the platform but can’t demonstrate it for reasons shown.
I have already flagged this thread for the attention of the support team. They (naturally) can see what is happening in the background.
As I have demonstrated, the code does work when deployed. What the difference is between you and I running exactly the same commands on exactly the same repository, I do not know.
The only other difference I can note is difference NodeJS/NPM versions
InvalidZipFileException: Lambda was not able to unzip the file
This usually means that the zip that was uploaded, was somehow incorrect or corrupted. If you were generating the zip manually, I’d have asked you to check that, but since you’re using CLI - it should work correctly.
Since @coelmay was able to deploy and run the functions correctly, I don’t think it has anything to do with how the function code is or how it’s being generated. This to me, looks like a system-level issue on your machine. Three things to try:
Does deploying via Git work? I’d highly assume that, it would, but let’s still check.
Are you able to deploy the same repo using CLI from a different device?
Could you check if the zips generated locally inside the .netlify folders look valid - that is, they extract and work correctly?
Unless I do ntl buildI don’t see any zip files. If I do ntl build I get the zips but they’re weird when extracted!
For hello-world I get .netlify/functions/hello-world/ and in there I get a 0 byte hello-world.js file and then an src directory and in there the source file for hello-world.
For mail it’s worse! I get netlify/functions/hello-world/ a zero-byte file and a src directory BUT in the src directory I get node_modules directory and then another netlify/functions/mail/mail.js. It’s very strange!
So, it’s definitely the CLI not the code itself!
Should it automatically create the zips when you’re doing ntl deploy? And what structure should they have??