Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling a sls webpack serve endpoint throws "TypeError: func is not a function" #46

Closed
marcuswhybrow opened this issue Oct 11, 2016 · 12 comments

Comments

@marcuswhybrow
Copy link

func represents the handler function defined in serverless.yml.

It seems this block initially sets handlerFunc (later referred to as func) to null. Setting it to funcConf.handler.split('.')[0] fixes the issue.

However, it looks like we have webpack setting the handlerFunc later on. I'm not sure what loadHandler does, or why it's important.

I searched the webpack docs and source but couldn't find reference to a loadHandler.

@smkamranqadri
Copy link

same issue with me!

@rivertam
Copy link

loadHandler is in lib/run. I haven't been able to figure out exactly why it's resulting in null only some times.

@perry-birch
Copy link

perry-birch commented Oct 23, 2016

Try setting output definition in webpack.config.js:
libraryTarget: 'commonjs2',

@rivertam
Copy link

@PerryBirch changes nothing

@thenikso
Copy link
Contributor

the loadHandler is used to reload the function from disk to address hot reloading. There might be a problem with how hot reloading is implemented that does not produce a "func" but I'm not quite sure why. Has anyone had more luck in debugging this issue?

@rvaidya
Copy link
Contributor

rvaidya commented Nov 17, 2016

I get this error only before the .webpack folder has been created - the console looks like it's ready and serving routes even though the webpack build is still happening in the background.

@briananderson1222
Copy link

Is there any more news on this or steps to get around it?

@fersman
Copy link

fersman commented Dec 21, 2016

In my case the problem was that starting my function failed. And then I got this error. Try to add this to beggining of your handler (it will report errors):

process.on('uncaughtException', function (err) {
console.log(err);
});

@thenikso
Copy link
Contributor

I was able to reproduce it last time but it seams fixed for me in the latest rc.3

Are you still expecting this issue?

@EQuimper
Copy link

EQuimper commented Mar 1, 2017

I got this error in version rc.4

@rvaidya
Copy link
Contributor

rvaidya commented Mar 1, 2017

As of my PR (#58) using serverless-offline (https://github.com/dherault/serverless-offline) together with serverless-webpack should be the way to go for local testing

@HyperBrain
Copy link
Member

serve will be removed in the next v3.0.0 release in favor of serverless-offline (see #152 ). No efforts will be spent on the function anymore. So I'll close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants