lightning icon indicating copy to clipboard operation
lightning copied to clipboard

Do not treat waitanyinvoice timeout on REST as an error

Open leocape opened this issue 2 years ago • 1 comments

Issue and Steps to Reproduce

Currently when requesting the waitanyinvoice endpoint with a timeout, and the timeout is reached (no new invoices paid) it throws an error, and shows an error in the logs. Personally I think this is expected behaviour, not an error (if we assume an error indicates that something has gone wrong / something unexpected has happened), if possible it would be a nice to have to have it return as possibly a HTTP 205 Reset Content? (200/20x would be ok too), which lets the client know that they must resend the request.

The main reason being is that I poll the node for new invoices, with a timeout of 30 seconds, and if it times out I send the request again. (I don't want to leave it waiting indefinitely, although perhaps that is the expected design and the node can sustain an indefinite wait any invoice? ). The logs look messy with these errors littered throughout..

EG log shown: 2024-01-22T17:38:29.095Z INFO plugin-clnrest.py: RPC Error: {'code': 904, 'message': 'Timed out while waiting for invoice to be paid'}

leocape avatar Jan 22 '24 17:01 leocape

@leocape Thanks for the suggestion but do you have any specific reason for not using web-socket instead of polling?

The clnrest server auto subscribes to all events including invoice_creation and invoice_payment from CLN and broadcasts to the client. Some web-socket client reference examples are available at rest documentation and recipes page.

ShahanaFarooqui avatar Feb 21 '24 19:02 ShahanaFarooqui

Closing the issue after 4 months of inactivity, will reopen if required.

ShahanaFarooqui avatar Jun 25 '24 19:06 ShahanaFarooqui