question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nootification not sent from AWS lambdas

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
idanlocommented, Jul 9, 2020

Can we have an official solution for this? More than a year with no actual solution

1reaction
hilkeheremanscommented, Oct 13, 2020

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found