alexbosworth / ln-service

Node.js interface to LND
MIT License
318 stars 61 forks source link

Do I need to poll to ensure that emitters created with `subscribeTo...` will emit anything? #177

Closed andreashuber69 closed 1 year ago

andreashuber69 commented 1 year ago

As far as I my tests indicate, the emitters created by at least some of the subscribeTo... functions will quietly stop working when LND restarts. So I guess I need to periodically monitor that LND is still alive and resubscribe when I detect that LND has restarted?

alexbosworth commented 1 year ago

None of them throw an error event?

andreashuber69 commented 1 year ago

None of them throw an error event?

You mean when calling subscribeToBlocks while LND is down, for example? I did not test that. I trust that it would throw.

I only tested calling subscribeToBlocks when LND is still up. I then call on on the returned emitter and finally restart LND after subscribing. Since the docs do not mention a separate error event, I did not try to subscribe to that. After restarting LND I did not get any "block" events anymore. I guess that is as designed, I was just wondering whether there's an easier way to detect that I need to resubscribe?

alexbosworth commented 1 year ago

all of the subscriptions have error events, i would hook onto that

andreashuber69 commented 1 year ago

all of the subscriptions have error events, i would hook onto that

Indeed, an "error" event is emitted when LND shuts down. Thanks!