How to use the @grpc/grpc-js.status.CANCELLED 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 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 googleapis / nodejs-pubsub / test / pull-retry.ts View on Github external
it('should use a backoff factoring in the failure count', () => {
      const random = Math.random();
      const expected = Math.pow(2, 1) * 1000 + Math.floor(random * 1000);

      sandbox.stub(global.Math, 'random').returns(random);

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

      assert.strictEqual(retrier.createTimeout(), 0);
    });
github LN-Zap / zap-desktop / services / grpc / lightning.subscriptions.js View on Github external
call.on('error', error => {
    if (error.code !== status.CANCELLED) {
      grpcLog.error('INVOICES ERROR: %o', error)
      this.emit('subscribeInvoices.error', error)
    }
  })
  call.on('status', status => {
github LN-Zap / zap-desktop / services / grpc / grpc.js View on Github external
this.activeSubscriptions[key].on('status', callStatus => {
        if (callStatus.code === status.CANCELLED) {
          delete this.activeSubscriptions[key]
          grpcLog.info(`Unsubscribed from ${key} gRPC stream`)
          resolve()
        }
      })
github LN-Zap / zap-desktop / app / lib / lnd / subscribe / channelgraph.js View on Github external
  call.on('error', error => error.code !== status.CANCELLED && mainLog.error(error))
  call.on('status', channelGraphStatus => {
github googleapis / nodejs-pubsub / src / pull-retry.ts View on Github external
*      http://www.apache.org/licenses/LICENSE-2.0
 *
 * 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
 */
github LN-Zap / zap-desktop / app / lib / lnd / subscribe / invoices.js View on Github external
  call.on('error', error => error.code !== status.CANCELLED && mainLog.error(error))
  call.on('status', status => mainLog.info('INVOICE STATUS:', status))
github LN-Zap / zap-desktop / services / grpc / grpcService.js View on Github external
call.on('status', callStatus => {
        if (callStatus.code === status.CANCELLED) {
          delete this.subscriptions[key]
          grpcLog.info(`Unsubscribed from ${this.serviceName}.${key} gRPC stream`)
          resolve()
        }
      })
    })
github LN-Zap / zap-desktop / app / lib / lnd / subscribe / transactions.js View on Github external
  call.on('error', error => error.code !== status.CANCELLED && mainLog.error(error))
  call.on('status', status => mainLog.info('TRANSACTION STATUS: ', status))