Merge pull request #2251 from mempool/nymkappa/bugfix/clightning-crash
Don't throw an exception when cln connection is down
This commit is contained in:
commit
c0e6b7af58
@ -157,8 +157,18 @@ export default class CLightningClient extends EventEmitter implements AbstractLi
|
|||||||
|
|
||||||
const _self = this;
|
const _self = this;
|
||||||
|
|
||||||
this.client = createConnection(rpcPath);
|
this.client = createConnection(rpcPath).on(
|
||||||
this.rl = createInterface({ input: this.client })
|
'error', () => {
|
||||||
|
_self.increaseWaitTime();
|
||||||
|
_self.reconnect();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
this.rl = createInterface({ input: this.client }).on(
|
||||||
|
'error', () => {
|
||||||
|
_self.increaseWaitTime();
|
||||||
|
_self.reconnect();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
this.clientConnectionPromise = new Promise<void>(resolve => {
|
this.clientConnectionPromise = new Promise<void>(resolve => {
|
||||||
_self.client.on('connect', () => {
|
_self.client.on('connect', () => {
|
||||||
@ -175,7 +185,6 @@ export default class CLightningClient extends EventEmitter implements AbstractLi
|
|||||||
|
|
||||||
_self.client.on('error', error => {
|
_self.client.on('error', error => {
|
||||||
logger.err(`[CLightningClient] Lightning client connection error: ${error}`);
|
logger.err(`[CLightningClient] Lightning client connection error: ${error}`);
|
||||||
_self.emit('error', error);
|
|
||||||
_self.increaseWaitTime();
|
_self.increaseWaitTime();
|
||||||
_self.reconnect();
|
_self.reconnect();
|
||||||
});
|
});
|
||||||
|
@ -9,6 +9,7 @@ import { ILightningApi } from '../../api/lightning/lightning-api.interface';
|
|||||||
import { $lookupNodeLocation } from './sync-tasks/node-locations';
|
import { $lookupNodeLocation } from './sync-tasks/node-locations';
|
||||||
import lightningApi from '../../api/lightning/lightning-api-factory';
|
import lightningApi from '../../api/lightning/lightning-api-factory';
|
||||||
import { convertChannelId } from '../../api/lightning/clightning/clightning-convert';
|
import { convertChannelId } from '../../api/lightning/clightning/clightning-convert';
|
||||||
|
import { Common } from '../../api/common';
|
||||||
|
|
||||||
class NetworkSyncService {
|
class NetworkSyncService {
|
||||||
constructor() {}
|
constructor() {}
|
||||||
@ -23,14 +24,15 @@ class NetworkSyncService {
|
|||||||
}, 1000 * 60 * 60);
|
}, 1000 * 60 * 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async $runUpdater() {
|
private async $runUpdater(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
logger.info(`Updating nodes and channels...`);
|
logger.info(`Updating nodes and channels...`);
|
||||||
|
|
||||||
const networkGraph = await lightningApi.$getNetworkGraph();
|
const networkGraph = await lightningApi.$getNetworkGraph();
|
||||||
if (networkGraph.nodes.length === 0 || networkGraph.edges.length === 0) {
|
if (networkGraph.nodes.length === 0 || networkGraph.edges.length === 0) {
|
||||||
logger.info(`LN Network graph is empty, retrying in 10 seconds`);
|
logger.info(`LN Network graph is empty, retrying in 10 seconds`);
|
||||||
setTimeout(this.$runUpdater, 10000);
|
await Common.sleep$(10000);
|
||||||
|
this.$runUpdater();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user