the_smart_home_maker
the_smart_home_maker

Reputation: 524

Serverless framework: All of a sudden receiving "ERROR TypeError: e is not a function" after deployment of service

Dear Stackoverflow community,

I am using the serverless framework to deploy my JS services to AWS. It always worked perfectly but since today, after deploying a little change to one of my functions' code, I am receiving the following error when calling any function in the service:

ERROR   TypeError: e is not a function
    at Runtime.handler (/var/task/serverless_sdk/index.js:9:137343)
    at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)

I do not understand where this comes from. I did not change the serverless.yml at all, also I did not change any basics of the function code (only a small change in an SQL statement, has nothing to do with the JavaScript code at all). I have read the following question Serverless framework TypeError: e is not a function but nothing described there fits to my situation.

Some more context information:

Does anybody have an idea where this might come from all of a sudden?

EDIT 1: I have also already upgraded the serverless framework - did not help

EDIT 2: The strange thing is that this problem occured all of a sudden while I had not changed any code - that's why I did not think posting any code would help. Now I am also experiencing this problem in further services that I want to deploy. I cannot deploy any function any more. As soon as I deploy a single function or a full service that did not have the issue before, the issue arises there as well. @PatrykMilewski: I checked the Lambda console and what I realized is that after deploying, the file that contains my function ("function.js") IS EMPTY whereas for services that had been deployed previously, the file IS NOT EMPTY. I would assume this might be the reason for the error message. Could this be caused by a bug in the serverless framework?

EDIT 3: I just remembered that I recently upgraded Mac OS to the latest version including new XCode Command Line Tools v13. From a time perspective, this could coincide with the issue popping up - could this be related to the problem?

EDIT 4: Some more environment information:

From my operating system:

ProductName:    macOS
ProductVersion: 11.6
BuildVersion:   20G165

From Serverless console output:

Operating System:          darwin
Node Version:              16.10.0
Framework Version:         2.10.0 (local)
Plugin Version:            4.1.1
SDK Version:               2.3.2
Components Version:        3.3.0

Upvotes: 2

Views: 2877

Answers (1)

the_smart_home_maker
the_smart_home_maker

Reputation: 524

Together with the very helpful support from the serverless team, I was able to resolve the issue. The reason for the issue actually was an outdated serverless version which I was not aware of. Usually I use yarn upgrade to upgrade all of my packages regularly. But in this case there was a dependency which forced serverless to stay on an outdated version. Only after proactively forcing serverless to upgrade to the latest version using yarn upgrade [email protected] and then afterwards calling once more yarn upgrade to also make the dependent packages based upon the new serverless version, I was able to upgrade serverless and its dependencies. After that, I deployed my services again and the error described above disappeared when calling my functions remotely.

I hope this also will help someone else who comes across this issue.

Upvotes: 3

Related Questions