I have a very simple lambda function that creates a file in a Github repo. Running it locally using netlify-lambda the function completes, successfully writing he file to the github repo, but there are warnings that cause the function to exit in an errored state.
When I run the code outside of the lambda function there are no errors or warnings.
@perry Thanks for the reply. I had originally tried to add the error
messages and some code snippets to the post, but the discourse forum
software kept blocking me from posting. Perhaps I’ll be able to add
the details here by replying to your comment via email reply.
These were the errors:
(node:2612) [DEP0005] DeprecationWarning: Buffer() is deprecated due
to security and usability issues. Please use the Buffer.alloc(),
Buffer.allocUnsafe(), or Buffer.from() methods instead.
(node:2612) UnhandledPromiseRejectionWarning: TypeError: Cannot read
property ‘statusCode’ of undefined
(node:2612) UnhandledPromiseRejectionWarning: Unhandled promise
rejection. This error originated either by throwing inside of an async
function without a catch block, or by rejecting a promise which was
not handled with .catch(). (rejection id: 1)
(node:2612) [DEP0018] DeprecationWarning: Unhandled promise rejections
are deprecated. In the future, promise rejections that are not handled
will terminate the Node.js process with a non-zero exit code.
Hi, it looks like you’re trying to use the async/await method but also use a (synchronous) callback function. You won’t be able to do that. Use one or the other. Your function is formatted mostly synchronously, so maybe try without the async keyword:
I still can’t figure out how to paste code snippets into the forum. OK I figured the code paste out finally.
FYI, I used 3 backticks, which is exactly what I did initially but was blocked by the discourse forum software from posting unless I removed all code and error messages. I just tried to update the previous posts that have the horrible looking code snippets, but the edit button no longer appears on the posts.