Sentry Express middleware and errorhandler not working with AWS Serverless Express
See original GitHub issueRaven errorhandler does not seem to capture the errors to Sentry when using it with AWS Serverless Express on AWS Lambda.
Following the sentry express example from https://docs.sentry.io/clients/node/integrations/express/ and then also the AWS Serverless Express example from https://github.com/awslabs/aws-serverless-express i get the following serverless handler.js file:
var app = require('express')();
var Raven = require('raven');
var awsServerlessExpress = require('aws-serverless-express')
// Must configure Raven before doing anything else with it
Raven.config(global.process.env.SENTRY_DSN).install();
// The request handler must be the first middleware on the app
app.use(Raven.requestHandler());
app.get('/', function mainHandler(req, res) {
throw new Error('Broke!');
});
// The error handler must be before any other error middleware
app.use(Raven.errorHandler());
const server = awsServerlessExpress.createServer(app);
exports.handler = (event, context) => awsServerlessExpress.proxy(server, event, context);
Using:
"raven": "2.6.3",
"aws-serverless-express": "3.2.0",
"express": "4.16.3",
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
Error handling with aws-serverless-express - node.js
I am using aws-serverless-express to provide an AWS Lambda handler for my Express webservice. The Lambda works, however, I am not able to ......
Read more >Sentry with AWS Lambda & Express - Integrations
Hey Guys, I've successfully integrated Sentry.io with my Express app on my local and I got it to report any issue.
Read more >Express | Sentry Documentation
The error handler must be before any other error middleware and after all controllers app.use(Sentry.Handlers.errorHandler()); // Optional fallthrough error ...
Read more >Lambda Error Logging With Sentry - Oliver Roick
Setting up Sentry error logging for a Lambda function is not as straightforward as, say, using a Django middleware. This post explores how ......
Read more >How to use Middy to validate your serverless API requests
Middy is a very simple middleware engine that allows you to simplify your AWS Lambda code when using Node.js. It allows you to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ondrowan thanks for the repro case, it’s very useful! We found out that the issue is with
serverless
wrapping everything in adomain
, which we ourselves use in express middlewares (that’s why it works with justnode handler.js
). We are working on the fix as we speak.From version 4 of sentry-node the
captureException
function no longer accepts a callback so the solution described above is no longer working. Do you have any plans to re-add this?