Comments (1)
Hi,
In summary
The CORS error is a secondary error caused by a previous error of a missing package (aws-xray-sdk-core) in AWS Lambda.
Workaround fix
Generate local installation of all packages (libraries) and then deploy them together in AWS Lambda.
In details
When checking the CloudWatch logs of the AWS Lambda functions It can be seen the error of a missing package/library aws-xray-sdk-core
:
2021-03-23T00:17:07.587Z undefined ERROR Uncaught Exception {
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 'aws-xray-sdk-core'\nRequire stack:\n- /var/task/app.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"stack": [
"Runtime.ImportModuleError: Error: Cannot find module 'aws-xray-sdk-core'",
"Require stack:",
"- /var/task/app.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/index.js",
" at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
" at Object.<anonymous> (/var/runtime/index.js:43:30)",
" at Module._compile (internal/modules/cjs/loader.js:999:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)",
" at Module.load (internal/modules/cjs/loader.js:863:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:708:14)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)",
" at internal/main/run_main_module.js:17:47"
]
}
Currently the AWS Lambda functions only require/depend on these 3 packages:
"aws-sdk": "^2.823.0",
"aws-embedded-metrics": "^2.0.2",
"aws-xray-sdk-core": "^3.2.0"
The aws-sdk
seems to be already included in AWS Lambda (no error about it). However, the xray library seems to be missing (or there is some internal bug).
I tested with NodeJS 14 version of AWS Lambda and the xray library was not available there either.
Workaround fix
I did npm install
inside the todo-src\getAllTodo
folder then did another sam deploy
and it was fine.
The CORS error disappeared.
I created a bash script to do the install of the libraries in all function folders:
cd todo-src/
cd addTodo; npm install; cd ..
cd completeTodo; npm install; cd ..
cd deleteTodo; npm install; cd ..
cd getAllTodo; npm install; cd ..
cd getTodo; npm install; cd ..
cd updateTodo; npm install; cd ..
cd ..
Feedback
- Check with the AWS Lambda team on why the
aws-xray-sdk-core
library is not available. - Furthermore, it will be useful to expand/update this page: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html and give detailed list of all libraries/packages and their version supported by AWS Lambda.
- Deploying the whole installation of packages is not user friendly as the code gets zipped and is not visible in AWS portal.
Regards,
Iviglious
from lambda-refarch-webapp.
Related Issues (20)
- running locally failure due to server task missed in gulpfile.js HOT 1
- link to diagram in READ.md failing HOT 7
- Bad performance in lambda functions HOT 2
- cloudformation failed at confighelperstack HOT 5
- Add overview of DynamoDB design HOT 2
- Cloud formation stack giving error...please help HOT 5
- Fix text and resolution on the diagram image HOT 1
- Users aren't restricted to their own todo items HOT 2
- CognitoID / aws_user_pools_id config on client unused? HOT 4
- Template miss spell HOT 1
- Unable to Login - redirects back to login page HOT 2
- Unable to delete the Todo HOT 2
- After deploy, AWS Amplify needs to be run manually HOT 5
- Unsecure - User token passed in URL
- Frontend headers generation source
- AWS SAM Template - link does not exist HOT 1
- Unable to test locally HOT 2
- More real world
- Unable to delete and complete Todo HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lambda-refarch-webapp.