How to use the @grpc/grpc-js.status.DEADLINE_EXCEEDED function in @grpc/grpc-js

To help you get started, we’ve selected a few @grpc/grpc-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleapis / nodejs-pubsub / test / pull-retry.ts View on Github external
it('should reset the failure count on DEADLINE_EXCEEDED', () => {
      retrier.retry({code: status.CANCELLED} as StatusObject);
      retrier.retry({code: status.DEADLINE_EXCEEDED} as StatusObject);

      assert.strictEqual(retrier.createTimeout(), 0);
    });
  });
github googleapis / nodejs-pubsub / test / pull-retry.ts View on Github external
it('should return true for retryable errors', () => {
      [
        status.OK,
        status.CANCELLED,
        status.UNKNOWN,
        status.DEADLINE_EXCEEDED,
        status.RESOURCE_EXHAUSTED,
        status.ABORTED,
        status.INTERNAL,
        status.UNAVAILABLE,
        status.DATA_LOSS,
      ].forEach((code: status) => {
        const shouldRetry = retrier.retry({code} as StatusObject);
        assert.strictEqual(shouldRetry, true);
      });
    });
github cjihrig / grpc-server-js / lib / server-call.js View on Github external
function handleExpiredDeadline (call) {
  call.sendError(new Error('Deadline exceeded'), Status.DEADLINE_EXCEEDED);
  call.cancelled = true;
  call.emit('cancelled', 'deadline');
}
github LN-Zap / node-lnd-grpc / src / grpc.js View on Github external
await this.services.WalletUnlocker.unlockWallet({}, { deadline: getDeadline(PROBE_TIMEOUT) })
    } catch (error) {
      switch (error.code) {
        /*
          `UNIMPLEMENTED` indicates that the requested operation is not implemented or not supported/enabled in the
           service. This implies that the wallet is already unlocked, since the WalletUnlocker service is not active.
           See

           `DEADLINE_EXCEEDED` indicates that the deadline expired before the operation could complete. In the case of
           our probe here the likely cause of this is that we are connecting to an lnd node where the `noseedbackup`
           flag has been set and therefore the `WalletUnlocker` interace is non-functional.

           https://github.com/grpc/grpc-node/blob/master/packages/grpc-native-core/src/constants.js#L129.
         */
        case status.UNIMPLEMENTED:
        case status.DEADLINE_EXCEEDED:
          debug('Determined wallet state as:', WALLET_STATE_ACTIVE)
          walletState = WALLET_STATE_ACTIVE
          return walletState

        /**
          `UNKNOWN` indicates that unlockWallet was called without an argument which is invalid.
          This implies that the wallet is waiting to be unlocked.
        */
        case status.UNKNOWN:
          debug('Determined wallet state as:', WALLET_STATE_LOCKED)
          walletState = WALLET_STATE_LOCKED
          return walletState

        /**
          Bubble all other errors back to the caller and abort the connection attempt.
          Disconnect all services.
github googleapis / nodejs-pubsub / src / message-stream.ts View on Github external
constructor(err: Error) {
    super(
      `Failed to connect to channel. Reason: ${
        process.env.DEBUG_GRPC ? err.stack : err.message
      }`
    );
    this.code = err.message.includes('deadline')
      ? status.DEADLINE_EXCEEDED
      : status.UNKNOWN;
    this.details = err.message;
    this.metadata = new Metadata();
  }
}
github googleapis / nodejs-pubsub / src / pull-retry.ts View on Github external
* Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import {StatusObject, status} from '@grpc/grpc-js';

/*!
 * retryable status codes
 */
export const RETRY_CODES: status[] = [
  status.OK,
  status.CANCELLED,
  status.UNKNOWN,
  status.DEADLINE_EXCEEDED,
  status.RESOURCE_EXHAUSTED,
  status.ABORTED,
  status.INTERNAL,
  status.UNAVAILABLE,
  status.DATA_LOSS,
];

/**
 * Used to track pull requests and determine if additional requests should be
 * made, etc.
 *
 * @class
 * @private
 */
export class PullRetry {
  private failures = 0;