-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ref(serverless): Added option ignoreSentryErrors for lambda WrapperOptions #4620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -11,7 +11,7 @@ import { | |||||||||||||||||||||||||||||
} from '@sentry/node'; | ||||||||||||||||||||||||||||||
import { extractTraceparentData } from '@sentry/tracing'; | ||||||||||||||||||||||||||||||
import { Integration } from '@sentry/types'; | ||||||||||||||||||||||||||||||
import { isString, logger } from '@sentry/utils'; | ||||||||||||||||||||||||||||||
import { isString, logger, SentryError } from '@sentry/utils'; | ||||||||||||||||||||||||||||||
// NOTE: I have no idea how to fix this right now, and don't want to waste more time, as it builds just fine — Kamil | ||||||||||||||||||||||||||||||
// eslint-disable-next-line import/no-unresolved | ||||||||||||||||||||||||||||||
import { Context, Handler } from 'aws-lambda'; | ||||||||||||||||||||||||||||||
|
@@ -53,6 +53,7 @@ export interface WrapperOptions { | |||||||||||||||||||||||||||||
* @default false | ||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||
captureAllSettledReasons: boolean; | ||||||||||||||||||||||||||||||
ignoreSentryErrors: boolean; | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
export const defaultIntegrations: Integration[] = [...Sentry.defaultIntegrations, new AWSServices({ optional: true })]; | ||||||||||||||||||||||||||||||
|
@@ -224,6 +225,7 @@ export function wrapHandler<TEvent, TResult>( | |||||||||||||||||||||||||||||
captureTimeoutWarning: true, | ||||||||||||||||||||||||||||||
timeoutWarningLimit: 500, | ||||||||||||||||||||||||||||||
captureAllSettledReasons: false, | ||||||||||||||||||||||||||||||
ignoreSentryErrors: false, | ||||||||||||||||||||||||||||||
...wrapOptions, | ||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||
let timeoutWarningTimer: NodeJS.Timeout; | ||||||||||||||||||||||||||||||
|
@@ -314,7 +316,13 @@ export function wrapHandler<TEvent, TResult>( | |||||||||||||||||||||||||||||
clearTimeout(timeoutWarningTimer); | ||||||||||||||||||||||||||||||
transaction.finish(); | ||||||||||||||||||||||||||||||
hub.popScope(); | ||||||||||||||||||||||||||||||
await flush(options.flushTimeout); | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as an argument, here is similar error nullification on flushing operation for google functions sentry-javascript/packages/serverless/src/gcpfunction/events.ts Lines 57 to 63 in 1bf9883
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for traditional ExpressJS/Koa sentry-javascript/packages/node/src/handlers.ts Lines 403 to 409 in 1bf9883
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. additionally, as i understand, 'flush' operation may be time consuming, so here it can affect lambda execution time even on successful invocation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Afaik this will not work in the case of AWS, as it will freeze the process immediately after reaching return value of the function. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep, you are right, with freezing the process, we can't do anything after the event, only via Lambda Extension, which is not our case. btw, in this PR i only propose to ignore sentry errors, same as in GCP and regular expressJs/Koa, they ignore sentry errors as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kamilogorek may i ask you to clarify what exact updates you requested There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I had a brain-fart for a second, as I was almost certain you changed from |
||||||||||||||||||||||||||||||
await flush(options.flushTimeout).catch(e => { | ||||||||||||||||||||||||||||||
if (options.ignoreSentryErrors && e instanceof SentryError) { | ||||||||||||||||||||||||||||||
logger.error(e); | ||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
throw e; | ||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
return rv; | ||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default value does not change current behaviour