-
Notifications
You must be signed in to change notification settings - Fork 168
Payment timeout #667
Payment timeout #667
Conversation
src/action/payment.js
Outdated
| const timeout = setTimeout(() => resolve(false), PAYMENT_TIMEOUT); | ||
| stream.on('data', data => { | ||
| if (data.payment_error) { | ||
| clearTimeout(timeout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we're clearing the timeout here regardless of the conditional. Can we move it outside the conditional (below line 179) and delete line 184?
tanx
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@valentinewallace I refactored the code a bit because it would have navigated twice in some cases. Let me know if it makes sense like this. Good to merge from my side.
| */ | ||
| async payLightning() { | ||
| let failed = false; | ||
| const timeout = setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can I test this block manually? In my local simnet environment I'm always getting an error from the stream data.payment_error and it just shows the notification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested by manually putting a sleep before the failed check, forcing a timeout. Not the most robust 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@valentinewallace well, that's one way of doing it :D.
444ac3d to
c8b6989
Compare
The timeout needs to be in the sendPayment promise to ensure that we resolve the promise on timeout, otherwise it might resolve/reject later on. This could cause undesirable side effects such as navigating to the success screen or showing an unexpected notification.
c8b6989 to
133c753
Compare
Time out payments after 1 minute.
Closes #555