Browse Source

Added catch for another error code when stream is removed forcefully

feature/dockerfile-arm
Gonzalo Javier Aune 5 years ago
parent
commit
4362d58ff6
  1. 5
      api/grpc/index.ts
  2. 5
      dist/api/grpc/index.js
  3. 2
      dist/api/grpc/index.js.map

5
api/grpc/index.ts

@ -10,6 +10,7 @@ import * as path from 'path'
const constants = require(path.join(__dirname,'../../config/constants.json')) const constants = require(path.join(__dirname,'../../config/constants.json'))
const ERR_CODE_UNAVAILABLE = 14 const ERR_CODE_UNAVAILABLE = 14
const ERR_CODE_STREAM_REMOVED = 2
// VERIFY PUBKEY OF SENDER // VERIFY PUBKEY OF SENDER
async function parseAndVerifyPayload(data){ async function parseAndVerifyPayload(data){
@ -173,7 +174,7 @@ function subscribeInvoices(actions) {
call.on('status', function(status) { call.on('status', function(status) {
console.log("Status", status); console.log("Status", status);
// The server is unavailable, trying to reconnect. // The server is unavailable, trying to reconnect.
if (status.code == ERR_CODE_UNAVAILABLE) { if (status.code == ERR_CODE_UNAVAILABLE || status.code == ERR_CODE_STREAM_REMOVED) {
reconnectToLND(); reconnectToLND();
} else { } else {
resolve(status); resolve(status);
@ -181,7 +182,7 @@ function subscribeInvoices(actions) {
}) })
call.on('error', function(err){ call.on('error', function(err){
console.error(err) console.error(err)
if (err.code == ERR_CODE_UNAVAILABLE) { if (err.code == ERR_CODE_UNAVAILABLE || err.code == ERR_CODE_STREAM_REMOVED) {
reconnectToLND(); reconnectToLND();
} else { } else {
reject(err) reject(err)

5
dist/api/grpc/index.js

@ -20,6 +20,7 @@ const moment = require("moment");
const path = require("path"); const path = require("path");
const constants = require(path.join(__dirname, '../../config/constants.json')); const constants = require(path.join(__dirname, '../../config/constants.json'));
const ERR_CODE_UNAVAILABLE = 14; const ERR_CODE_UNAVAILABLE = 14;
const ERR_CODE_STREAM_REMOVED = 2;
// VERIFY PUBKEY OF SENDER // VERIFY PUBKEY OF SENDER
function parseAndVerifyPayload(data) { function parseAndVerifyPayload(data) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
@ -184,7 +185,7 @@ function subscribeInvoices(actions) {
call.on('status', function (status) { call.on('status', function (status) {
console.log("Status", status); console.log("Status", status);
// The server is unavailable, trying to reconnect. // The server is unavailable, trying to reconnect.
if (status.code == ERR_CODE_UNAVAILABLE) { if (status.code == ERR_CODE_UNAVAILABLE || status.code == ERR_CODE_STREAM_REMOVED) {
reconnectToLND(); reconnectToLND();
} }
else { else {
@ -193,7 +194,7 @@ function subscribeInvoices(actions) {
}); });
call.on('error', function (err) { call.on('error', function (err) {
console.error(err); console.error(err);
if (err.code == ERR_CODE_UNAVAILABLE) { if (err.code == ERR_CODE_UNAVAILABLE || err.code == ERR_CODE_STREAM_REMOVED) {
reconnectToLND(); reconnectToLND();
} }
else { else {

2
dist/api/grpc/index.js.map

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save