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

Uploading source map doesn't work when deploying function only #67

Open
fancywriter opened this issue Jun 24, 2022 · 1 comment
Open
Labels

Comments

@fancywriter
Copy link

fancywriter commented Jun 24, 2022

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

const zip = new AdmZip(artifact);

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...

@fancywriter
Copy link
Author

@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. 🙈 Not sure if putting 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.

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

No branches or pull requests

2 participants