Serverless-webpack: sls deploy function -f <function> not respecting entry slsw.lib.entries

Created on 21 Mar 2021  路  18Comments  路  Source: serverless-heaven/serverless-webpack

Bug Report

Description

Hi, I searched for this error but I could not find anything related.

serverless-webpack @ 5.3.5 works perfectly.

serverless-webpack @ 5.4.0 does not work as expected.

When I try to update only one function it tries to copy all the functions declared inside the serverless and not the one from slsw.lib.entries.

The whole process occurs OK, compilation and zip generation for just the function from slsw.lib.entries. But when the final process kicks in to copy the artifacts from .webpack to .serverless the plugin search for all the functions generation this error message (the function on the error message is the one not listed inside slsw.lib.entries):

ENOENT: no such file or directory, copyfile '/...../.webpack/<function>.zip' -> '.serverless/<function>.zip'

Obs.: I removed the full path and function name for simplicity.

  • Serverless-Webpack Version you're using: 5.4.0
  • Webpack version you're using: 5.27.1
  • Serverless Framework Version you're using: 2.28.7
  • Operating System: Mac OS X 10.15.7
  • Stack Trace (if available):
Error: ENOENT: no such file or directory, copyfile '/......./.webpack/<function>.zip' -> '.serverless/<function>.zip'
      at Object.copyFileSync (fs.js:1991:3)
      at ServerlessWebpack.copyArtifactByName (/....../node_modules/serverless-webpack/lib/packageModules.js:86:6)
bug

Most helpful comment

Hello :wave: ~Does someone have, by any chance, a minimal reproducible example that I could run on my side in order to debug/diagnose the problem?~ Nvm, managed to reproduce, will try to post PR with a fix as soon as possible.

All 18 comments

I noticed this today, too. I can still do sls deploy, but if I try to deploy a single function via deploy -f, I get the error you mentioned.

Just tried on some projects using Webpack 4 without issue.
Does everyone having that issue is using Webpack 5?

@j0k3r
Got this on a project using webpack: 4.46.0.
Failed on serverless-webpack 5.4.0, reverted to 5.3.5 and it worked.

Used the sls deploy -f function command.

Which serverless version are you all using : 1.x or 2.x ?

Yeah, same issue here on Webpack 5.

    "webpack": "^5.27.2",
    "webpack-node-externals": "^2.5.2"

Sls info:

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              12.14.1
     Framework Version:         2.28.7
     Plugin Version:            4.4.3
     SDK Version:               2.3.2
     Components Version:        3.7.2

Downgrade to sls webpack 5.3.5 solves the issue as well.

I made some debugs here and maybe the problem is with the individually: true option. Because when turned off all the functions are zipped not the one selected with function -f and everything works.

@j0k3r Take a look if your project works with this option turned on:

package:
  individually: true

On a semi-related note: why would anyone ever want package.individually: false if you have several Lambda functions in one Serverless project? I wouldn't want the same code bundled for all of my 20+ functions.

Like a beacon in the night I find this thread.

This too has just started happening for me. All is well in the world when I deploy as a whole; but if I attempt to do a single function, then it breaks, saying it is missing the file for my authorizer for that function.

SLS 2.31.0.

I downgraded to 5.3.5 and all is well in the world

@ffxsam The framework has this option, so I don't know all the cases. But maybe the plugin is not checking for this option and trying to copy the entire stack of functions.

Like @ffxsam said, package.individually: false is not optimal.
Currently, the only option is to downgrade to v.5.3.5 or turn off the package.individually flag.
Neither should be a solution.

I'd be glad if someone could review what caused the regression between v.5.3.5 and v.5.4.0.

@j0k3r Does 5.4.1 fix this issue?

@j0k3r Does 5.4.1 fix this issue?

Nope. Otherwise the ticket will be closed

This is indeed still broken. Downgraded to 5.3.5 as a workaround.

I think this was caused by #560

Looking at the stack trace from the output:

```
Error: ENOENT: no such file or directory, copyfile '/Users/username/path/.webpack/verify.zip' -> '.serverless/verify.zip'
at copyFileSync (fs.js:1912:3)
at Object.copyFileSync (/snapshot/serverless/lib/utils/standalone-patch.js:55:5)
at ServerlessPlugin.copyArtifactByName (/Users/username/path/node_modules/serverless-webpack/lib/packageModules.js:86:6)
at /Users/username/path/node_modules/serverless-webpack/lib/packageModules.js:133:66
````

It points to this section of code:

https://github.com/serverless-heaven/serverless-webpack/blob/2371550b7e6b2161e5dc954ec61b3a1b55e6eb8e/lib/packageModules.js#L131-L136

Which seems to be getting all the function names even if only as single function is being processed.

Any updates on this? I'd love to upgrade to 5.4.x to get rid of the CLI options deprecation warning I keep seeing every time I deploy.

Maybe @jamesmbourne will have some insight since that's his PR.

Hello :wave: ~Does someone have, by any chance, a minimal reproducible example that I could run on my side in order to debug/diagnose the problem?~ Nvm, managed to reproduce, will try to post PR with a fix as soon as possible.

@pgrzesik Awesome! Let's hope for a merge & publish soon. Thanks for your help.

I'll check that next week!
Thanks @pgrzesik

Was this page helpful?
0 / 5 - 0 ratings