serverless-plugin-warmup: ImportModuleError
I have a rather simple serverless config, with no other plugins, no package exclude patters, yet I get a ModuleImportError upon deployment. The only potential deviation from the most basic example in the README is that I’ve configured Serverless to build and deploy an image rather than a zip. Any ideas?
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 's_warmUpPluginWarmer'\nRequire stack:\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"trace": [
"Runtime.ImportModuleError: Error: Cannot find module 's_warmUpPluginWarmer'",
"Require stack:",
"- /var/runtime/UserFunction.js",
"- /var/runtime/index.js",
" at _loadUserApp (/var/runtime/UserFunction.js:202:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:242:17)",
" at Object.<anonymous> (/var/runtime/index.js:43:30)",
" at Module._compile (internal/modules/cjs/loader.js:1085:14)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)",
" at Module.load (internal/modules/cjs/loader.js:950:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:790:12)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)",
" at internal/main/run_main_module.js:17:47"
]
}
My Serverless config:
provider:
name: aws
region: eu-west-1
memorySize: 1024
timeout: 900 #sec
deploymentBucket:
name: ${opt:stage}-smp-serverless-deployment
iam:
role: ${ssm:/${opt:stage}-lambda-serverless-role-arn}
ecr:
images:
appimage:
path: ./
plugins:
- serverless-plugin-warmup
functions:
main:
name: ${opt:stage}-conv
environment:
INPUT_S3_BUCKET: ${ssm:/${opt:stage}-file-upload-bucket-name}
image:
name: appimage
custom:
warmup:
warmer:
enabled: true
package:
events:
- schedule: rate(10 minutes)
concurrency: 10`
Many thanks in advance!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 30 (11 by maintainers)
Hi @juanjoDiaz, I was facing this same issue but the proposed workaround didn’t work for me. However, I found a fix!
In my case, I’m using both
serverless-plugin-warmupfor warmups andserverless-esbuildfor bundling/minifying.In the
pluginssection, if I listserverless-esbuildBEFOREserverless-plugin-warmup, it fails to package theserverless_sdkfolder and thes_warmupPluginDefault.jsfile. If I moveserverless-esbuildafterserverless-plugin-warmup, however, it packages everything properly.For example. This does not work:
However, this does work:
I assume it has something to do with lifecycle hooks competing between esbuild and warmup, but I don’t know for sure.
@juanjoDiaz Thanks for the prompt response. My mistake on the version number, that was a mistype on my end! 7.1.0 is the one I am on.
So I actually just got everything working on my end using what minu2020 had pasted above (adding in the package options to my config) on Feb 1, 2022. I’m still not entirely sure what the issue was, but everything seems to be alright now.
The warmup config that I am now using successfully is:
@juanjoDiaz Its working fine for me after adding the following under custom.warmup.default