UNPKG

@camunda8/sdk

Version:

[![NPM](https://nodei.co/npm/@camunda8/sdk.png)](https://www.npmjs.com/package/@camunda8/sdk)

43 lines (42 loc) 2.25 kB
import { BeforeErrorHook, BeforeRetryHook, HandlerFunction, Method } from 'got'; import { CamundaPlatform8Configuration } from './Configuration'; /** * Capturing useful async stack traces is challenging with got. * See here: https://github.com/sindresorhus/got/blob/main/documentation/async-stack-traces.md * This function stores the call point from the application of got requests. * This enables users to see where the error originated from. */ export declare const beforeCallHook: HandlerFunction; /** * This function is used to handle 401 errors in got requests. * It will retry the request only once if the error code is 401. * Otherwise, for 429 and 503 errors, it will retry according to the GotRetryConfig. */ export declare const gotBeforeRetryHook: BeforeRetryHook; /** * This function adds the call point to the error stack trace of got errors. * This enables users to see where the error originated from. * * It also logs the error to the Camunda Support log. * This is useful for debugging and support purposes. */ export declare const gotBeforeErrorHook: (config: CamundaPlatform8Configuration) => BeforeErrorHook; /** * * This function is used on a 401 response to retry the request with a new token, one single time. * https://github.com/camunda/camunda-8-js-sdk/issues/125 */ export declare const makeBeforeRetryHandlerFor401TokenRetry: (getHeadersFn: any) => (context: any) => Promise<void>; /** * Retry configuration for got requests. * This configuration is used to retry requests on certain status codes and methods. * We will retry on 429 (Too Many Requests) and 503 (Service Unavailable) status codes. * 503 is used for Camunda 8 to indicate server backpressure. See: https://github.com/camunda/camunda-8-js-sdk/issues/509 * 401 (Unauthorized) is used for OAuth token refreshes. * We will retry only once on 401 (see the BeforeRetryHook), because the worker polls continuously, and a worker that is misconfigured with an invalid secret will retry indefinitely. * This is not ideal, but it is the current behaviour. We need to ensure that such a worker does not flood the broker, so we cause a backoff. */ export declare const GotRetryConfig: { methods: Method[]; statusCodes: number[]; };