(context: Context, options: WrapperOptions)
| 111 | } |
| 112 | |
| 113 | function 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 | |
| 138 | export const AWS_HANDLER_HIGHWATERMARK_SYMBOL = Symbol.for('aws.lambda.runtime.handler.streaming.highWaterMark'); |
| 139 | export const AWS_HANDLER_STREAMING_SYMBOL = Symbol.for('aws.lambda.runtime.handler.streaming'); |
no test coverage detected