Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
});
});
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.
*/
default:
console.error(error)
debug('Unable to determine wallet state', error)
throw error
}
} finally {
if (!options.keepalive && this.can('disconnect')) {
await this.disconnect()
sendError (error, code = Status.UNKNOWN) {
const { status } = this;
if ('message' in error) {
status.details = error.message;
} else {
status.details = 'Unknown Error';
}
if ('code' in error && Number.isInteger(error.code)) {
status.code = error.code;
if ('details' in error && typeof error.details === 'string') {
status.details = error.details;
}
} else {
status.code = code;
*
* 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 {
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();
}
}