()
| 225 | timeoutWarningTimer = setupTimeoutWarning(context, options); |
| 226 | |
| 227 | async function processResult(): Promise<TResult> { |
| 228 | const scope = getCurrentScope(); |
| 229 | |
| 230 | let rv: TResult; |
| 231 | try { |
| 232 | enhanceScopeWithEnvironmentData(scope, context, START_TIME); |
| 233 | |
| 234 | rv = await asyncHandler(event, context); |
| 235 | |
| 236 | // We manage lambdas that use Promise.allSettled by capturing the errors of failed promises |
| 237 | if (options.captureAllSettledReasons && Array.isArray(rv) && isPromiseAllSettledResult(rv)) { |
| 238 | const reasons = getRejectedReasons(rv); |
| 239 | reasons.forEach(exception => { |
| 240 | captureException(exception, scope => markEventUnhandled(scope, 'auto.function.aws_serverless.promise')); |
| 241 | }); |
| 242 | } |
| 243 | } catch (e) { |
| 244 | // Errors should already be captured in the AwsLambda instrumentation's error handler, |
| 245 | // we capture them here just to be safe. Double captures are deduplicated by the SDK. |
| 246 | captureException(e, scope => markEventUnhandled(scope, 'auto.function.aws_serverless.handler')); |
| 247 | throw e; |
| 248 | } finally { |
| 249 | clearTimeout(timeoutWarningTimer); |
| 250 | await flush(options.flushTimeout).catch(e => { |
| 251 | DEBUG_BUILD && debug.error(e); |
| 252 | }); |
| 253 | } |
| 254 | return rv; |
| 255 | } |
| 256 | |
| 257 | return withScope(async () => { |
| 258 | return processResult(); |
no test coverage detected