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

Function setupTimeoutWarning

packages/aws-serverless/src/sdk.ts:113–136  ·  view source on GitHub ↗
(context: Context, options: WrapperOptions)

Source from the content-addressed store, hash-verified

111}
112
113function setupTimeoutWarning(context: Context, options: WrapperOptions): NodeJS.Timeout | undefined {
114 // In seconds. You cannot go any more granular than this in AWS Lambda.
115 const configuredTimeout = Math.ceil(tryGetRemainingTimeInMillis(context) / 1000);
116 const configuredTimeoutMinutes = Math.floor(configuredTimeout / 60);
117 const configuredTimeoutSeconds = configuredTimeout % 60;
118
119 const humanReadableTimeout =
120 configuredTimeoutMinutes > 0
121 ? `${configuredTimeoutMinutes}m${configuredTimeoutSeconds}s`
122 : `${configuredTimeoutSeconds}s`;
123
124 if (options.captureTimeoutWarning) {
125 const timeoutWarningDelay = tryGetRemainingTimeInMillis(context) - options.timeoutWarningLimit;
126
127 return setTimeout(() => {
128 withScope(scope => {
129 scope.setTag('timeout', humanReadableTimeout);
130 captureMessage(`Possible function timeout: ${context.functionName}`, 'warning');
131 });
132 }, timeoutWarningDelay) as unknown as NodeJS.Timeout;
133 }
134
135 return undefined;
136}
137
138export const AWS_HANDLER_HIGHWATERMARK_SYMBOL = Symbol.for('aws.lambda.runtime.handler.streaming.highWaterMark');
139export const AWS_HANDLER_STREAMING_SYMBOL = Symbol.for('aws.lambda.runtime.handler.streaming');

Callers 2

wrapHandlerFunction · 0.85
wrappedHandlerFunction · 0.85

Calls 5

withScopeFunction · 0.90
setTimeoutFunction · 0.85
setTagMethod · 0.80
captureMessageFunction · 0.50

Tested by

no test coverage detected