You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Single function deploy does not invoke the plugin #107
I do not know if this is a problem with Serverless' lifecycle events or if it is a problem within the webpack plugin. If I try to upload a single function during development, using serverless deploy function -f auth the webpack build is not triggered and Serverless tries to upload the whole project which exceeds the upload file size limit of 70MB.
When deploying the complete service with serverless deploy the plugin is invoked correctly and the resulting function code ZIP is about 17MB.
Serverless: Deploying function: auth...
Serverless: Packaging function: auth...
Serverless: Uploading function: auth (90.02 MB)...
Serverless Error ---------------------------------------
Request must be smaller than 69905067 bytes for the
UpdateFunctionCode operation
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Your Environment Information -----------------------------
OS: win32
Node Version: 4.3.1
Serverless Version: 1.6.1
If it turns out that the problem is on Serverless' side, we should create an issue there.
Reacted by Roy Firestein, Steven Inskip, Pontus Aurdal and Ben
I analyzed the issue and found the root cause (also copied in the references serverless issue):
The webpack plugin is invoked on the 'before:deploy:createDeploymentArtifacts' and 'after:deploy:createDeploymentArtifacts' hooks, which are not exposed by the AWS function deploy core plugin (there only 'deploy:function:packageFunction' is available). That's why the webpack packing is not invoked at all in this case.
The correct solution would be to hook 'before:deploy:function:packageFunction' and package the requested function chunk.
Did not have time to investigate the problem with my PR further. Currently I am implementing parts of the new package/deploy mechanism in Serverless and try to keep it compatible with the existing plugins.
Nevertheless there will be big improvements in Serverless' lifecycle model that should make it a lot easier to support hooking multiple commands with one hook.
I will try to fix and test this during the lifecycle development.
@nicolasdonoso Which serverless-webpack plugin version did you use? The support for package individually is currently implemented and available in the v3.0.0-individual-packaging branch which will be integrated into the upcoming v3 version.
serverless-webpack v2.x.x does not yet support it.
Can you give that branch a try and check if it solves the problem for you?
@HyperBrain thanks for the response, I added the branch that you are telling me and deployed the hole project and I get the following error:
Cannot set property 'package' of undefined
Stack Trace --------------------------------------------
This happens when adding:
individually: true
After that I tried to deploy a single function and it states "Serverless: Bundling with Webpack..." what wasn't happening on previous versions, but after that I get the following error:
ENOENT: no such file or directory, open '.../<project-name>/.webpack/.serverless/<function-name>.zip'
Stack Trace --------------------------------------------
@nicolasdonoso Thanks for testing 👍 . Can you check that you have
package:
individually: true
at the top-level of your serverless.yml? And verify that the handler definitions in the functions point to the correct relative paths in case you have your handler files sitting somewhere within your project.
Additionally it would be great to see your webpack.conf.js to check if the configuration there is correct. There's now the possibility to enable automatic entry/handler resolution in the webpack config. I'm quite sure it's only some configuration issue.
@HyperBrain Yes I have that on top-level of my serverless.yml. The handler definitions are pointing correctly and its generating the .webpack folder with all the functions inside as individual folders. Now its logging me the following error:
Cannot set property 'package' of undefined
My webpack.config.js is the following:
module.exports = {
//entry: "./functions/*.js",
entry: fn_register,//_.assign(fn_register, slsw.lib.entries),
target: 'node',
module: {
loaders: [{
test: /\.js$/,
loaders: ['babel-loader'],
include: __dirname,
exclude: /node_modules/,
},
{
test: /aws-sdk/,
loaders: ['transform-loader?aws-sdk/dist-tools/transform']
},
{
test: /\.json$/,
loaders: ['json-loader']
}]
},
output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, './.webpack'),
filename: '[name].js'
}
};```
** fn_register is an object thats mapping all the entry names and paths of my functions.
Can you try to use entry: slsw.lib.entries to test if the manual override causes the problem?
Additionally you can let the error create a callstack by setting SLS_DEBUG=* in your environment.
Then it is better to check.
We just tried what you told us, and it works. But we are getting this response from our function once its deployed: Bad handler ./functions/model/job_request/get_details.handler
Can you open/extract the zip file the deployment created in .serverless for your function and check what's exactly in there?
Also check in your serverless.yml that the handler definition of your function is this:
I double checked our serverless.yml and the definition was affecting the deployment.
I was using ./functions....
After removing the "./" it worked.
Thanks for the help!
Thanks for the info. I think you just found a small bug of the single function deploy together with the individual packaging.
Could you create an issue "V3: Deploying a single function with individual packaging does not work"
I will take care of it and fix it soon.
Activity
HyperBrain commentedon Mar 2, 2017
I analyzed the issue and found the root cause (also copied in the references serverless issue):
The webpack plugin is invoked on the 'before:deploy:createDeploymentArtifacts' and 'after:deploy:createDeploymentArtifacts' hooks, which are not exposed by the AWS function deploy core plugin (there only 'deploy:function:packageFunction' is available). That's why the webpack packing is not invoked at all in this case.
The correct solution would be to hook 'before:deploy:function:packageFunction' and package the requested function chunk.
jdbevan commentedon Mar 3, 2017
I guess the difficulty here is determining which webpack entry points map to which services in the serverless config.
Hooking into the correct events is a lot easier.
jtrein commentedon Mar 23, 2017
Any more progress on #110 ?
HyperBrain commentedon Mar 23, 2017
Did not have time to investigate the problem with my PR further. Currently I am implementing parts of the new package/deploy mechanism in Serverless and try to keep it compatible with the existing plugins.
Nevertheless there will be big improvements in Serverless' lifecycle model that should make it a lot easier to support hooking multiple commands with one hook.
I will try to fix and test this during the lifecycle development.
jtrein commentedon Mar 23, 2017
Appreciate the update!
HyperBrain commentedon Jul 3, 2017
Shifted to 2.1.0 as there are still discussions on how to improve the implementation provided in #130 .
HyperBrain commentedon Jul 26, 2017
PR #130 is merged.
nicolasdonoso commentedon Aug 3, 2017
Hi,
I'm running webpack 2.7.0 and serverless 1.19.0 and the problem still persist.
Adding
Gives me the following error when deploying:
Is anything that I'm missing or wrongly configuring?
HyperBrain commentedon Aug 4, 2017
@nicolasdonoso Which serverless-webpack plugin version did you use? The support for package individually is currently implemented and available in the
v3.0.0-individual-packagingbranch which will be integrated into the upcoming v3 version.serverless-webpack v2.x.x does not yet support it.
Can you give that branch a try and check if it solves the problem for you?
nicolasdonoso commentedon Aug 4, 2017
@HyperBrain thanks for the response, I added the branch that you are telling me and deployed the hole project and I get the following error:
This happens when adding:
After that I tried to deploy a single function and it states "Serverless: Bundling with Webpack..." what wasn't happening on previous versions, but after that I get the following error:
HyperBrain commentedon Aug 4, 2017
@nicolasdonoso Thanks for testing 👍 . Can you check that you have
at the top-level of your serverless.yml? And verify that the
handlerdefinitions in the functions point to the correct relative paths in case you have your handler files sitting somewhere within your project.Additionally it would be great to see your webpack.conf.js to check if the configuration there is correct. There's now the possibility to enable automatic entry/handler resolution in the webpack config. I'm quite sure it's only some configuration issue.
nicolasdonoso commentedon Aug 4, 2017
@HyperBrain Yes I have that on top-level of my serverless.yml. The handler definitions are pointing correctly and its generating the .webpack folder with all the functions inside as individual folders. Now its logging me the following error:
My webpack.config.js is the following:
HyperBrain commentedon Aug 4, 2017
Can you try to use
entry: slsw.lib.entriesto test if the manual override causes the problem?Additionally you can let the error create a callstack by setting
SLS_DEBUG=*in your environment.Then it is better to check.
nicolasdonoso commentedon Aug 4, 2017
We just tried what you told us, and it works. But we are getting this response from our function once its deployed:
Bad handler ./functions/model/job_request/get_details.handlerHyperBrain commentedon Aug 4, 2017
Can you open/extract the zip file the deployment created in
.serverlessfor your function and check what's exactly in there?Also check in your
serverless.ymlthat the handler definition of your function is this:nicolasdonoso commentedon Aug 4, 2017
I double checked our serverless.yml and the definition was affecting the deployment.
I was using ./functions....
After removing the "./" it worked.
Thanks for the help!
HyperBrain commentedon Aug 4, 2017
😃 You're welcome
nicolasdonoso commentedon Aug 4, 2017
The whole project deploys correctly, but when deploying individual functions I'm getting the following error:
HyperBrain commentedon Aug 4, 2017
Thanks for the info. I think you just found a small bug of the single function deploy together with the individual packaging.
Could you create an issue "V3: Deploying a single function with individual packaging does not work"
I will take care of it and fix it soon.
nicolasdonoso commentedon Aug 4, 2017
Ok, just created a new issue #181