iopipe / serverless-iopipe-layers

Please migrate to the equivalent New Relic Serverless plugin: serverless-newrelic-lambda-layers
https://github.com/iopipe/serverless-newrelic-lambda-layers
Apache License 2.0
14 stars 8 forks source link

handler errors with serverless enterprise #28

Closed adjohn closed 5 years ago

adjohn commented 5 years ago

User reported issue where the handler is being configured differently from how IOpipe sets it, and ends up with a module not found error.

Error when invoking:

"errorMessage": "Cannot find module './/opt/nodejs/node_modules/@iopipe/iopipe.js'",
"trace": [
"Error: Cannot find module './/opt/nodejs/node_modules/@iopipe/iopipe.js'",
" at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)",
" at Module._require.o.require (/var/task/serverless_sdk/index.js:9:88803)",
" at require (internal/modules/cjs/helpers.js:22:18)",
" at Object.<anonymous> (/var/task/s_appsyncOdsResolver.js:12:23)",
" at Module._compile (internal/modules/cjs/loader.js:701:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)",
" at Module.load (internal/modules/cjs/loader.js:600:32)",
" at tryModuleLoad (internal/modules/cjs/loader.js:539:12)",
" at Function.Module._load (internal/modules/cjs/loader.js:531:3)",
" at Module.require (internal/modules/cjs/loader.js:637:17)"
]
}

Upon investigation, the handler was set incorrectly to s_appsyncOdsResolver.handler instead of /opt/nodejs/node_modules/@iopipe/iopipe.handler

Manually changing the handler via the AWS console to /opt/nodejs/node_modules/@iopipe/iopipe.handler fixed the issue.

I suspect that AppSync plugin could be messing with the handler after we configure it.

adjohn commented 5 years ago

Turns out that when using Serverless enterprise, they modify the handler which breaks IOpipe. Modifying the handler above is a workaround but users may lose some functionality from Serverless enterprise.