bug(verifier): startMonitor resolves successfully after watchBlocks startup failure
Describe the bug
Verifier.startMonitor() catches errors thrown while creating/subscribing to the watch blocks observable, logs them, deletes the monitor entry, but does not rethrow or reject:
} catch (err) {
this.log.error(`##Error: startMonitor, ${err}`);
this.runningMonitors.delete(appId);
}
Because the method returns Promise<void>, callers can receive a resolved promise even though monitoring failed to start.
To Reproduce
- Use a ledger API client whose
watchBlocksV1()orwatchBlocksAsyncV1()throws, rejects, or returns no observable. - Call
await verifier.startMonitor(appId, options, listener). - Observe that the call resolves after logging the error instead of rejecting.
Expected behavior
startMonitor() should reject when the monitor cannot be started, so callers can handle the failure and avoid assuming monitoring is active.
Actual behavior
startMonitor() swallows the startup error and resolves successfully after logging.
Impact
Applications can believe block/event monitoring is active when it failed to start. This can make monitoring failures silent unless logs are inspected.
Suggested fix
Rethrow the caught error after cleanup, or return a status/result that explicitly tells callers the monitor was not started.
Hey @RafaelAPB @malsomesh9 I would like to work on this issue My understanding of the issue In Verifier.startMonitor(), the catch block logs the error and cleans up runningMonitors but never rethrows. Since it's an async function, the swallowed exception causes the promise to resolve instead of reject — callers have no way to know monitoring failed.
My fix Add a rethrow in the catch block so the error propagates to the caller. Also update the existing test in verifier.test.ts which was written expecting the broken behavior (asserting the promise resolves on error) — it should instead assert that the promise rejects.
Can I be assigned to this, or should I open a PR directly?