MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / wrappedHandler

Function wrappedHandler

packages/aws-serverless/src/sdk.ts:270–306  ·  view source on GitHub ↗
(
    event: TEvent,
    responseStream: Parameters<StreamifyHandler<TEvent, TResult>>[1],
    context: Context,
  )

Source from the content-addressed store, hash-verified

268 let timeoutWarningTimer: NodeJS.Timeout | undefined;
269
270 const wrappedHandler = async (
271 event: TEvent,
272 responseStream: Parameters<StreamifyHandler<TEvent, TResult>>[1],
273 context: Context,
274 ): Promise<TResult> => {
275 context.callbackWaitsForEmptyEventLoop = options.callbackWaitsForEmptyEventLoop;
276
277 timeoutWarningTimer = setupTimeoutWarning(context, options);
278
279 async function processStreamingResult(): Promise<TResult> {
280 const scope = getCurrentScope();
281
282 try {
283 enhanceScopeWithEnvironmentData(scope, context, startTime);
284
285 responseStream.on('error', error => {
286 captureException(error, scope => markEventUnhandled(scope, 'auto.function.aws_serverless.stream'));
287 });
288
289 return await handler(event, responseStream, context);
290 } catch (e) {
291 // Errors should already be captured in the AwsLambda instrumentation's error handler,
292 // we capture them here just to be safe. Double captures are deduplicated by the SDK.
293 captureException(e, scope => markEventUnhandled(scope, 'auto.function.aws_serverless.handler'));
294 throw e;
295 } finally {
296 if (timeoutWarningTimer) {
297 clearTimeout(timeoutWarningTimer);
298 }
299 await flush(options.flushTimeout).catch(e => {
300 DEBUG_BUILD && debug.error(e);
301 });
302 }
303 }
304
305 return withScope(() => processStreamingResult());
306 };
307
308 const handlerWithSymbols = handler as unknown as Record<symbol, unknown>;
309 (wrappedHandler as unknown as Record<symbol, unknown>)[AWS_HANDLER_STREAMING_SYMBOL] =

Callers 4

http.test.tsFile · 0.50
sdk.test.tsFile · 0.50

Calls 3

withScopeFunction · 0.90
setupTimeoutWarningFunction · 0.85
processStreamingResultFunction · 0.85

Tested by

no test coverage detected