Comments (4)
I believe this is because you are catching the error, which implies it has been handled by the application.
if you rethrow the error after you send your responses, Sentry will report them.
'use strict';
const SparkPost = require('sparkpost');
const { decrypt, } = require('../crypto.js');
const RavenLambdaWrapper = require("serverless-sentry-lib");
// Wrap handler for automated error and exception logging
const ravenConfig = {
captureErrors: true,
captureUnhandledRejections: true,
captureMemoryWarnings: true,
captureTimeoutWarnings: true,
ravenClient: require("raven") // don't forget!
};
module.exports.index = RavenLambdaWrapper.handler(ravenConfig, (event, context, callback) => {
context.callbackWaitsForEmptyEventLoop = true;
const keys = event.requestContext.authorizer;
const body = JSON.parse(event.body);
console.log('event', JSON.stringify(body, 3));
const response = {
statusCode: 200,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': true,
},
body: '',
};
const client = new SparkPost(keys.SparkPostKey);
const RECIPIENT = body.RECIPIENT;
const TEMPLATE_ID = body.TEMPLATE_ID;
const CAMPAIGN_ID = body.CAMPAIGN_ID;
const SUBSTITUTION_DATA = body.SUBSTITUTION_DATA;
try {
if (SUBSTITUTION_DATA && SUBSTITUTION_DATA.confirmation_link) {
SUBSTITUTION_DATA.confirmation_link = decrypt(SUBSTITUTION_DATA.confirmation_link);
}
} catch (err) {
console.log('to decryption err', err);
response.statusCode = 400;
response.body = JSON.stringify({
status: 'Failed',
error: 'Decryption error in \'confirmation_link\'',
});
callback(null, response);
throw err;
}
client.transmissions.send({
options: {
track_opens: true,
track_clicks: true,
transactional: true,
ip_pool: "trans2"
},
campaign_id: CAMPAIGN_ID,
content: {
template_id: TEMPLATE_ID
},
substitution_data: SUBSTITUTION_DATA,
recipients: RECIPIENT
})
.then(data => {
console.log("Email has been sent. ", data);
response.body = JSON.stringify({
success: true,
data: data,
});
callback(null, response);
})
.catch(err => {
console.log(err);
response.statusCode = 400;
response.body = JSON.stringify({
success: false,
error: err,
});
callback(null, response);
throw err;
});
});
from serverless-sentry-plugin.
Hi @JakeChampion, I did that but the error still doesn't show up in Sentry.
I'm stuck to the Waiting for events… page...
from serverless-sentry-plugin.
Hello, same for me here, using Typescript and the new handler version, I even tried to call Raven.captureMessage("Hello from Lambda!");
without success.
I've setup the release and it work, but it doesn't log any message...how can I debug it?
from serverless-sentry-plugin.
I believe this is because you are catching the error, which implies it has been handled by the application.
if you rethrow the error after you send your responses, Sentry will report them.
.catch(err => { console.log(err); response.statusCode = 400; response.body = JSON.stringify({ success: false, error: err, }); callback(null, response); throw err; }); });
Thank you - I was facing the same issue where sentry would not pick up any errors logged within the lambda - the solution was to throw an error manually in the catch block such as throw err;
from serverless-sentry-plugin.
Related Issues (20)
- Create release failing on v2.0.0 HOT 2
- Cannot catch unhandled promise rejections HOT 8
- Add support for filtering events HOT 1
- READ.me file needs to be modified
- Any progress on uploading source maps? HOT 2
- Differences between this and official @sentry/serverless package HOT 2
- Add enable config
- Missing schema for `functions[].sentry` properties
- Serverless deployment fails with "fatal: No names found, cannot describe anything." HOT 23
- Plugin defines a validation schema that is invalid HOT 12
- Sentry: Error uploading sourcemap file - Error: connect EADDRNOTAVAIL 35.188.42.15:443 - Local HOT 27
- Repository name capturing from remote is wrong HOT 4
- Uploading source map doesn't work when deploying function only HOT 1
- Function Timeouts lack of information HOT 2
- Data scrubbing/Trace sampling feature request HOT 1
- [bug] [regression] Error: Sentry: Error deploying release - Error: Too Many Requests HOT 4
- Add support for @sentry/node v7
- enable CaptureConsole as an option
- Uploading source maps to sentry when using serverless-plugin-typescript
- Add Custom Tags
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 serverless-sentry-plugin.