Nootification not sent from AWS lambdas
See original GitHub issueI’m using serverless framework to deploy lamdbas containing bugsnag.
I’m using aws-serverless-express to have express running.
I had to write my own middleware to ensure the bugsnag request is fulfilled before finishing the lambda
From this file https://github.com/bugsnag/bugsnag-js/blob/next/packages/plugin-express/src/express.js#L49
I replaced this
const errorHandler = (err, req, res, next) => {
if (req.bugsnag) {
req.bugsnag.notify(createReportFromErr(err, handledState))
} else {
client._logger.warn(
'req.bugsnag is not defined. Make sure the @bugsnag/plugin-express requestHandler middleware is added first.'
)
client.notify(createReportFromErr(err, handledState, getRequestAndMetaDataFromReq(req)))
}
next(err)
}
by
app.use(async (err, req, res, next) => {
await new Promise(resolve => {
req.bugsnag.notify(createReportFromErr(err, handledState), {}, resolve)
})
next(err)
})
that way it ensures the request has been fulfilled.
Could this become an option?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:13 (4 by maintainers)
Top Results From Across the Web
Troubleshoot Amazon SNS not invoking a Lambda function
Confirm that your Lambda function has the permissions required to allow Amazon SNS to invoke the function. To view your function's permissions ...
Read more >How to Send an Email Notification Using AWS Lambda
First, you need to go to Amazon SNS and create a topic. You should create a topic, create a subscription and then publish...
Read more >Email notification through SNS and Lambda - Stack Overflow
The Lambda function can use the Instance ID to retrieve further details about the instance (eg server name, IP address). The function can...
Read more >AWS Lambda function - Send a email notification if ... - YouTube
This video brief's about simple use-case of aws lamda function Use case is Send a email notification if a particular instance is stopped....
Read more >Send an SNS notification using AWS Lambda
Send an SNS notification using AWS Lambda · 1. Initialize the Project · 2. Email · 3. Next, we bring it all together...
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
Can we have an official solution for this? More than a year with no actual solution
The new AWS Extensions API might offer good ways to solve this issue: https://docs.aws.amazon.com/lambda/latest/dg/runtimes-extensions-api.html