TypeError after functions within a service are packaged
kchecoBasis opened this issue · 14 comments
Getting a TypeError exception after warmup is invoked. We have a multi-service repo.
.warmup/peakHoursLambdaWarmer/index.js
4
`+new Array(N).join(" ")+"^"}}return null}function Z(g){var d=K(g),E=L();E&&E._handle&&E._handle.set
^ TypeError Cannot set property 'warmUp' of undefined
node: 14.x
serverless-bundle: 5.3.0
serverless-plugin-warmup: 7.1.0
Same here.
Same problem here
{
"errorType": "Runtime.HandlerNotFound",
"errorMessage": ".warmup/default/index.warmUp is undefined or not exported",
"stack": [
"Runtime.HandlerNotFound: .warmup/default/index.warmUp is undefined or not exported",
" at Object.module.exports.load (/var/runtime/UserFunction.js:246:11)",
" 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:75:12)",
" at internal/main/run_main_module.js:17:47"
]
}
- node: 14.x
- serverless-plugin-warmup: 6.2.1
- serverless: 2.23.x
Hi guys,
Sorry for the slow response.
Are all of you using the bundle or webpack plugin?
Are you declaring warmup after those plugins?
Can you provide a repo where I can reproduce this?
This is how we have our plugins listed in our common.serverless.yml in project root.
plugins:
- serverless-bundle
- serverless-offline
- serverless-domain-manager
- serverless-plugin-warmup
Then this is how we imported the plugins in our service config file as such:
plugins: ${file(../../common.serverless.yml):plugins}
Hi @kchecoBasis ,
I don't know how to reproduce the issue.
So, without a repo to reproduce I can't do much...
Hi, I fixed it with the following config:
plugins:
- serverless-bundle
- serverless-plugin-warmup
custom:
bundle:
esbuild: true
- node: 14
- serverless-bundle: 5.3.0
- serverless-plugin-warmup: 6.2.1
- serverless: 3.15.2
@kchecoBasis, @thiagosanches, @victorcsciandt maybe this will solve your problem
but, it doesn't work with serverless-plugin-warmup: 7.1.0
, error:
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 's_warmUpPluginDefault'\nRequire stack:\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"stack": [
"Runtime.ImportModuleError: Error: Cannot find module 's_warmUpPluginDefault'",
"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:75:12)",
" at internal/main/run_main_module.js:17:47"
]
}
This seems a problem between the plugins not using the lifecycle events consistently.
This is something that I already raised to the Serverless Framework maintainers.
Until, they are more prescriptive on how plugins should use lifecycles events, we can just workaround these kind of issue.
As said, until I have a project to reproduce, I can't do anything on this.
@juanjoDiaz - I think if you just create a blank project from this base:
serverless create --template aws-nodejs-typescript --path aws-serverless-typescript-api
then just install serverless-plugin-warmup
and add it at the end of plugins
in serverless.ts, try to deploy that and you'll be able to reproduce the issue.
Hi all,
After some research and looking deeply into #314, I found that the issue is in the serverless dashboard plugin which is using deprecated settings of serverless. I created the above PR and I hope that it gets merged soon.
I am experiencing the same issue.
A log entry from CloudWatch for one of my WarmUp Lambda functions using version 6.2.1 of the plugin:
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 's_warmUpPluginDefault'\nRequire stack:\n- /var/runtime/UserFunction.js\n- /var/runtime/Runtime.js\n- /var/runtime/index.js",
"stack": [
"Runtime.ImportModuleError: Error: Cannot find module 's_warmUpPluginDefault'",
"Require stack:",
"- /var/runtime/UserFunction.js",
"- /var/runtime/Runtime.js",
"- /var/runtime/index.js",
" at _loadUserApp (/var/runtime/UserFunction.js:221:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:279:17)",
" at Object.<anonymous> (/var/runtime/index.js:43:34)",
" 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:75:12)",
" at internal/main/run_main_module.js:17:47"
]
}
And for version 7.2.0 of the plugin:
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 's_warmUpPluginDefault'\nRequire stack:\n- /var/runtime/index.mjs",
"stack": [
"Runtime.ImportModuleError: Error: Cannot find module 's_warmUpPluginDefault'",
"Require stack:",
"- /var/runtime/index.mjs",
" at _loadUserApp (file:///var/runtime/index.mjs:726:17)",
" at async Object.module.exports.load (file:///var/runtime/index.mjs:741:21)",
" at async file:///var/runtime/index.mjs:781:15",
" at async file:///var/runtime/index.mjs:4:1"
]
}
I will watch for updates on the PR for serverless dashboard plugin.
Closing as the PR was merged.
Whenever the new dashboard plugin is added to the main framework, the issue should be solved.
Hi @juanjoDiaz,
Thank you for the PR on dashboard-plugin.
I'm still facing the issue, and since it might take a while for your changes to be added to the main framework, I was wondering if you are able to advise on a workaround.
I've upgraded to Serverless v3.22.0 and serverless-plugin-warmup v8.0.0.
The error message I see after invocation of the WarmUp Lambda function is:
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 's_warmUpPluginDefault'\nRequire stack:\n- /var/runtime/index.mjs",
"stack": [
"Runtime.ImportModuleError: Error: Cannot find module 's_warmUpPluginDefault'",
"Require stack:",
"- /var/runtime/index.mjs",
" at _loadUserApp (file:///var/runtime/index.mjs:726:17)",
" at async Object.module.exports.load (file:///var/runtime/index.mjs:741:21)",
" at async file:///var/runtime/index.mjs:781:15",
" at async file:///var/runtime/index.mjs:4:1"
]
}
I've also added serverless-bundle to my Serverless configuration, but without any effect.
Could you please take a look at this? Any help is much appreciated.
This issue is a duplicate of #293.
Look at the last message there for a workaround to manually add the s_warmUpPluginDefault
file to the warmer lambda.
Perfect, thank you @juanjoDiaz, and sorry for not looking at the other issues! My issue is resolved now.