node_modules/@google-cloud/firestore/build/src/index.js
/**
     * Helper method that retries failed Promises.
     *
     * If 'delayMs' is specified, waits 'delayMs' between invocations. Otherwise,
     * schedules the first attempt immediately, and then waits 100 milliseconds
     * for further attempts.
     *
     * @private
     * @param methodName Name of the Veneer API endpoint that takes a request
     * and GAX options.
     * @param requestTag A unique client-assigned identifier for this request.
     * @param func Method returning a Promise than can be retried.
     * @returns  - A Promise with the function's result if successful within
     * `attemptsRemaining`. Otherwise, returns the last rejected Promise.
     */
Helper method that retries failed Promises.
If 'delayMs' is specified, waits 'delayMs' between invocations. Otherwise,
schedules the first attempt immediately, and then waits 100 milliseconds
for further attempts.

@private
@param methodName Name of the Veneer API endpoint that takes a request
and GAX options.
@param requestTag A unique client-assigned identifier for this request.
@param func Method returning a Promise than can be retried.
@returns  - A Promise with the function's result if successful within
`attemptsRemaining`. Otherwise, returns the last rejected Promise.
Helper method that retries failed Promises . If ' delayMs ' is specified waits ' delayMs ' between invocations . Otherwise schedules the first attempt immediately and then waits 100 milliseconds for further attempts . @private @param methodName Name of the Veneer API endpoint that takes a request and GAX options . @param requestTag A unique client - assigned identifier for this request . @param func Method returning a Promise than can be retried . @returns - A Promise with the function ' s result if successful within ` attemptsRemaining ` . Otherwise returns the last rejected Promise .
async _retry(methodName, requestTag, func) {
        const backoff = new backoff_1.ExponentialBackoff();
        let lastError = undefined;
        for (let attempt = 0; attempt < MAX_REQUEST_RETRIES; ++attempt) {
            if (lastError) {
                logger_1.logger('Firestore._retry', requestTag, 'Retrying request that failed with error:', lastError);
            }
            try {
                await backoff.backoffAndWait();
                const result = await func();
                this._lastSuccessfulRequest = new Date().getTime();
                return result;
            }
            catch (err) {
                lastError = err;
                if (util_1.isPermanentRpcError(err, methodName, serviceConfig)) {
                    break;
                }
            }
        }
        logger_1.logger('Firestore._retry', requestTag, 'Request failed with error:', lastError);
        return Promise.reject(lastError);
    }
async _retry ( methodName , requestTag , func ) { const backoff = new backoff_1 . ExponentialBackoff ( ) ; let lastError = undefined ; for ( let attempt = 0 ; attempt < MAX_REQUEST_RETRIES ; ++ attempt ) { if ( lastError ) { logger_1 . logger ( 'Firestore._retry' , requestTag , 'Retrying request that failed with error:' , lastError ) ; } try { await backoff . backoffAndWait ( ) ; const result = await func ( ) ; this . _lastSuccessfulRequest = new Date ( ) . getTime ( ) ; return result ; } catch ( err ) { lastError = err ; if ( util_1 . isPermanentRpcError ( err , methodName , serviceConfig ) ) { break ; } } } logger_1 . logger ( 'Firestore._retry' , requestTag , 'Request failed with error:' , lastError ) ; return Promise . reject ( lastError ) ; }
Helper method that retries failed Promises.
Helper method that retries failed Promises .