-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1900 from bugsnag/node-remove-domain-3
capture uncaught exceptions in aws-lambda
- Loading branch information
Showing
6 changed files
with
136 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
test/aws-lambda/features/fixtures/simple-app/async/async-unhandled-exception.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const Bugsnag = require('@bugsnag/js') | ||
const BugsnagPluginAwsLambda = require('@bugsnag/plugin-aws-lambda') | ||
|
||
Bugsnag.start({ | ||
apiKey: process.env.BUGSNAG_API_KEY, | ||
endpoints: { | ||
notify: process.env.BUGSNAG_NOTIFY_ENDPOINT, | ||
sessions: process.env.BUGSNAG_SESSIONS_ENDPOINT | ||
}, | ||
plugins: [BugsnagPluginAwsLambda], | ||
autoDetectErrors: process.env.BUGSNAG_AUTO_DETECT_ERRORS !== 'false', | ||
autoTrackSessions: process.env.BUGSNAG_AUTO_TRACK_SESSIONS !== 'false' | ||
}) | ||
|
||
const bugsnagHandler = Bugsnag.getPlugin('awsLambda').createHandler() | ||
|
||
const handler = async (event, context) => { | ||
setTimeout(() => { | ||
throw new Error('Oh no!') | ||
}, 100) | ||
|
||
await new Promise(resolve => setTimeout(resolve, 1000)) | ||
|
||
return { | ||
statusCode: 200, | ||
body: JSON.stringify({ message: 'Did not crash immediately!' }) | ||
} | ||
} | ||
|
||
module.exports.lambdaHandler = bugsnagHandler(handler) |
46 changes: 46 additions & 0 deletions
46
test/aws-lambda/features/fixtures/simple-app/events/async/async-unhandled-exception.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"body": "", | ||
"resource": "/{proxy+}", | ||
"path": "/async/async/unhandled/exception", | ||
"httpMethod": "GET", | ||
"isBase64Encoded": false, | ||
"queryStringParameters": {}, | ||
"multiValueQueryStringParameters": {}, | ||
"pathParameters": {}, | ||
"stageVariables": {}, | ||
"headers": { | ||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", | ||
"Accept-Encoding": "gzip, deflate, sdch", | ||
"Accept-Language": "en-US,en;q=0.8", | ||
"Cache-Control": "max-age=0", | ||
"Host": "1234567890.execute-api.us-east-1.amazonaws.com", | ||
"Upgrade-Insecure-Requests": "1", | ||
"User-Agent": "Custom User Agent String" | ||
}, | ||
"requestContext": { | ||
"accountId": "123456789012", | ||
"resourceId": "123456", | ||
"stage": "prod", | ||
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef", | ||
"requestTime": "09/Apr/2015:12:34:56 +0000", | ||
"requestTimeEpoch": 1428582896000, | ||
"identity": { | ||
"cognitoIdentityPoolId": null, | ||
"accountId": null, | ||
"cognitoIdentityId": null, | ||
"caller": null, | ||
"accessKey": null, | ||
"sourceIp": "127.0.0.1", | ||
"cognitoAuthenticationType": null, | ||
"cognitoAuthenticationProvider": null, | ||
"userArn": null, | ||
"userAgent": "Custom User Agent String", | ||
"user": null | ||
}, | ||
"path": "/prod/async/async/unhandled/exception", | ||
"resourcePath": "/{proxy+}", | ||
"httpMethod": "GET", | ||
"apiId": "1234567890", | ||
"protocol": "HTTP/1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters