Uploading source map doesn't work when deploying function only
fancywriter opened this issue · 1 comments
If I deploy all project sls deploy -s mystage
it works fine as expected.
However, if I try to deploy only one function with sls deploy function -f myfunction -s mystage
I am getting an error Error: Invalid filename
on node_modules/adm-zip/adm-zip.js:57:19
caused by this line
serverless-sentry-plugin/src/index.ts
Line 459 in b0dd2d1
Because file .serverless/myFunction.zip
doesn't exist. In fact, whole directory is cleaned (dropped) when I run sls deploy function
.
Serverless version 3.10.1, sentry plugin 2.5.3.
I guess it should work the following - if file exists, reuse it, if not - build and pack it (and only one function). (I use package.individually = true
and serverless-bundle plugin).
Seems that serverless-bundle plugin uses serverless-webpack under the hood and I have checked that during sls deploy function
command a ZIP file inside directory .serverless
is actually created... however after that it is deleted before hook of sentry-plugin is called... I am still not sure which issue is it exactly, which of the plugin or the framework itself...
@arabold I found the root cause of this behaviour, I hope it could be interesting. This is more because of serverless itself (aws plugin which is part of core code base), though I am not sure what is the best way to solve it properly.
You can reproduce this too, correct? After examining the code and some debugging it seems it just can't work another way, so it's definitely not the problem with my configuration.
uploadSentrySourcemaps
method is added to two hooks - after:deploy:deploy
and after:deploy:function:deploy
which seems makes complete sense. Work for the first, but not for the last. This method relies on function(s) artifact(s), which is stored in serverless temporary directory .serverless
by default.
After both sls deploy
and sls deploy function
temp directory is cleaned, but in different way, for former it uses aws:deploy:finalize:cleanup event, but for latter it is last call inside deploy:function:deploy, not even some sort of after:deploy:function:deploy
.
I don't know what is mechanism to rely consistency between different hooks called by different plugin, seems it's poorly designed because I am reading advice "plugin xxx must be put after plugin yyy to work properly" on documentation pages. cleanupTempDir
call inside just after:deploy:function:deploy
may help... It may help or may not...
Solution should either make 1) sentry plugin not to rely on contents of temp directory, but to rely on what instead? 2) hooks must be managed properly, serverless deploy function must have separate hook for cleanup to leave a room for plugins relying on temp directory content.