question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`lambda is not a function` error thrown when handler is misspelled

See original GitHub issue

This is a (Bug Report)

Description

A Type Error is thrown (lambda is not a function) when the handler within serverless.yml is misspelled and the function is invoked locally. I feel like there could be a better check / error to report such an error.

For bug reports:

  • What went wrong? image

  • What did you expect should have happened? A more useful error message

  • What was the config you used? Any basic helloworld serverless.yml will do the trick.

  • What stacktrace or error message from your provider did you see? nil

Additional Data

To fix this bug, within the serverless.yml I went from:

createThingType:
    handler: handler.createThing

to:

createThingType:
    handler: handler.createThingType

There was no function in the handler file called createThing but there was a method called createThingType. Function was invoked using the following: $ DEBUG=* sls invoke local -f createThingType.

  • Provider Error messages: Type Error: lambda is not a function

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:17
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

43reactions
HoraceShmoracecommented, Dec 29, 2017

What is your proposal for a better error message? Imo, the error message that it is not a function is quite right here. Maybe telling, that the handler export does not exist would be a slight improvement though.

lambda is not a function is a terrible error message. I had no idea it meant that it couldn’t find the handler I specified. Couldn't find the specified handler function would be better.

9reactions
kbariotiscommented, Nov 5, 2017

@shahzeb1 I am suspecting that AWS doesn’t allows a handler file to export anything than a handler function. Correct me if I am wrong.

@HyperBrain +1 to add a check on whether the defined exported name is has actually been exported. We could also list all the exported functions of the file as a suggestion, like:

The handler doesn't export a function called "createThing". Did you mean "createThingType", "createAnotherThingType"?

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS Lambda function errors in Node.js
If Lambda encounters an error, it returns an exception type, message, and HTTP status code that indicates the cause of the error.
Read more >
TypeError: "x" is not a function - JavaScript - MDN Web Docs
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
Read more >
How to Handle JavaScript Uncaught TypeError: “x” is Not a ...
The Javascript error TypeError: "x" is not a function occurs when there is an attempt to call a function on a value or...
Read more >
Debugging with Dashbird: Lambda Configuration Error
This error can have many causes, but it simply means that the Lambda service can't reach your handler function. Lambda is a function...
Read more >
"Type Error: lambda is not a function" in handler with multiple ...
I have two functions in my handler.js file and I have configured them correctly in serverless.yml. The problem is, when I run invocation, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found