-
Notifications
You must be signed in to change notification settings - Fork 116
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
Unable to import module #25
Comments
@oleschaper provide more information such as:
(Edit): No, should work fine with all runtimes. Only the warmup lambda is written in Nodejs. |
Thank you, sorry here are a few more information. Serverless Version: Plugins:
I'm using the java8 runtime. I guess the problem is that the serverless warmup plugin is a runtime dependency and maven does not include any nodejs dependencies? |
Warmup lambda execution only depends on the available lambda runtime If it's a path issue and you have your warmup created. What is the path of the function handler in the console? Can you invoke your warmup manually? Let us know your findings. |
Hi, thank you for your reply! So the Lambda Function and Log Group is created. Not sure what you mean by "path of the function handler in the console"? Thank you for your help! |
Hello Same for me , i am running the project for aws-maven-java and i got same error above I Received the below
deploying was successful
but then checking the cloudwatch logs it shows
|
Cannot find module 'bluebird' |
when serverless-webpack go to pack the js file and they need this /***/ 0:
/***/ (function(module, exports) {
module.exports = require("babel-runtime/core-js/json/stringify");
/***/ }),
/***/ 2:
/***/ (function(module, exports) {
module.exports = require("bluebird"); There is the issue. |
Hi All, new CopyWebpackPlugin([
{ from: './node_modules/bluebird',
to: '_warmup/node_modules/bluebird'
},
{ from: './node_modules/babel-runtime',
to: '_warmup/node_modules/babel-runtime'
},
{ from: './node_modules/core-js',
to: '_warmup/node_modules/core-js'
}]) May be different project have different require. So please check _webpack/index.js |
Hi @yoyeung Thank you for your answer but I do not understand what you are talking about.
Thank you very much. |
I was reading the serverless docs about packaging again (https://serverless.com/framework/docs/providers/aws/guide/packaging#artifact) and it says:
So again, my guess would be that the warmup lambda js function/files are just not included in the artifact that is uploaded to aws because it is not in the jar file that maven generates (since it is not a java dependency) and serverless ONLY uploads that artifact file. Solution would be to include the needed files into the artifact by adding them to the maven pom.xml but I don't know what to include (something called Any help/thoughts? Thanks! |
Ok, so I found that you are using individual packaging for the warmup function here: Maybe this is also ignored by serverless if I use an artifact file? |
It is working for me now but the solution is not optimal. |
Hi @oleschaper. Thanks for discovering the cause of your issue. What comes to my mind as a solution is adding this logic within your artifact build logic:
|
Hi, yes that is what I ended up with basically, although I had to modify the plugin in line https://github.com/FidelLimited/serverless-plugin-warmup/blob/master/src/index.js#L154
otherwise it would delete the lambda function. |
Oh and the order of commands would be:
Not a very nice solution but it works and I don't see any other way for now. |
@oleschaper get the latest version and use I am closing this down. 👍 |
So how did you guys resolve the issue? Even with cleanFolder set false the issue still remains. |
@gamaro7 i have tried with |
I got that issue ... |
Same boat , ended up ditching this plugin and using https://www.npmjs.com/package/serverless-plugin-lambda-warmup?activeTab=readme . Just works and no PITA |
The problem was that last release had an issue getting SLS Previous versions were working fine. |
Thanks @goncaloneves |
Thank you @chaitanya11 👌 |
If anyone other (next to me) is struggling over this issue and has problems solving it with the above discussion: IssueWhen you install the plugin via npm and you run The solutionYou have to move the _warmup dir into your resources folder (src.main.resources) of your service. This folder will be unpacked by maven and will be added to the root of the .jar. AWS will search within this jar for a dir '_warmup' which consists of a index.js. In commandsAll commands are from the root of your service
'_warmup' will be created
move the folder to your resources dir
package the artifact
deploys the jar and here is my serverless.yml conf for the plugin
|
@AndrinGautschi Thanks for the clear info of what is happening. Just to confirm you are using the latest version Ok, I guess it took me a "while" to understand the issue here. I don't do manual artifacts on my deploy pipelines. Basically when defining a custom Serverless artifact package path the So solution for this is fetch the artifact path when is defined and have the _warmup folder in there instead. |
@goncaloneves Thanks for the fast reaction. Yes, I use the latest version. Yes that would do it I suppose. Another solution would be to make another configuration parameter to specify where the "_warmup" folder should be placed. Then we could specify by ourself. With a little doc update, this would solve the issue (hacky, but efficient). |
@AndrinGautschi Thanks for the reply. 👌 Having both options probably is the ideal solution, default sets root service path, artifact path if set, or plugin configurable path. That will tick all boxes. Hacking like pros hehe I will push this forward when I work on the plugin. |
@goncaloneves @AndrinGautschi I'm not using Maven (and my deployment happens via Jenkins), plus my directory structure seems to be a different to you guys':
When you say Like, should I make my structure like this:
And so on and so forth? EDIT: I've done this, but still getting:
For reference:
|
There seem to be multiple issues going on here. When packaging using When using serverless-webpack, it can't find _warmup |
Thinking a bit more about this... Would it be a solution to simply apply the So, instead of
use
That way, serverless still packages the lambdas individually and correctly generates the package for the warmup plugin. |
Actually, just created a PR in Serverless that fix the root cause of this issue (the Let's see if it can get merge and we won't need to workaround the issue 🙂 |
Alrighty! My PR is merged into Serverless. Essentially, now you can do:
So running serverless package with the above config will use Since serverless-plugin-warmup is set as |
EDIT: It works now for me. Flushing my node_modules and reinstalling seemed to do the trick.
My relevant serverless config is: plugins:
- serverless-plugin-warmup # I have tried this at the end of the list
- serverless-webpack
- serverless-plugin-tracing
- serverless-mocha-plugin
custom:
warmup:
default: false # We enable this per function
folderName: _warmup
schedule: rate(5 minutes)
cleanFolder: false
prewarm: true
package:
individually: true
functions:
myFunc:
handler: src/myFunc/handler.handler
warmup: true
events:
... The error message is:
|
Perfect @juanjoDiaz. Once again, terrific work. 🙌 |
Hi,
the plugin does not work for me, from CloudWatch Logs:
Does it only work if you are using nodejs runtime?
The text was updated successfully, but these errors were encountered: