Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark unrecoverable errors so they don't spawn #412

Merged
merged 3 commits into from
Jan 4, 2025

Conversation

DanGould
Copy link
Contributor

@DanGould DanGould commented Jan 2, 2025

Mark unrecoverable errors in storage so that they no longer spawn isolates.

Spawning isolates and failing them immediately uses more resources than necessary. This is therefore a performance improvement for the stability of the app.

In the medium term we should switch on errors from payjoin-flutter, but those errors are not yet available to switch on. This will reduce the amount of error definition and handling we have to manually implement, but since this is a potential immediate performance issue I'm addressing it straight away.

Mark unrecoverable sender errors in storage so that they no longer spawn
isolates.

Spawning isolates and failing them immediately uses more resources than
necessary. This is therefore a performance improvement for the stability
of the app.

In the medium term we should switch on errors from payjoin-flutter, but
those errors are not yet available to switch on. This will reduce
the amount of error definition and handling we have to manually implement,
but since this is a potential immediate performance issue I'm addressing
it straight away.
@DanGould DanGould force-pushed the handle-unrecoverable-pj branch from 1cf3a0b to fd2fc86 Compare January 2, 2025 20:39
This way they don't respawn if they're never going to succeed.
@DanGould DanGould marked this pull request as ready for review January 2, 2025 20:40
@DanGould DanGould closed this Jan 3, 2025
@DanGould DanGould reopened this Jan 3, 2025
@DanGould DanGould changed the title Mark unrecoverable Sender errors so they don't spawn Mark unrecoverable errors so they don't spawn Jan 3, 2025
@@ -281,6 +301,9 @@ class PayjoinManager {

return completer.future;
} catch (e) {
if (e is UnrecoverableError) {
Copy link
Contributor

@kumulynja kumulynja Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DanGould I think this never gets here and should be moved to the receive port listener where the UnrecoverableError is send to from the isolate. So I guess instead of the message is Err on line 283, check for and handle the UnrecoverableError there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this change as well as one where if errors in the switch statement crop up we mark the receiver payjoin session as unrecoverable which I detail in the commit message. Let me know what you think.

Receivers need to handle both switch errors or isolate errors. This change
takes the error handling out of the spawn try-catch, which would never receive
them and moves it into places where those errors would propagate.

Note that some of the switch errors like checkIsOwned might crop up
because of a wallet being improperly loaded, but for the time being we don't
have the granularity to distinguish between them.
@DanGould DanGould requested a review from kumulynja January 3, 2025 20:30
Copy link

@bitcoin-b bitcoin-b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@kumulynja kumulynja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works now 👍

@i5hi
Copy link
Collaborator

i5hi commented Jan 4, 2025

Thanks @DanGould!

Thanks @kumulynja and @bitcoin-b for the review!

@i5hi i5hi merged commit c518ffb into SatoshiPortal:main Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants