Skip to content

perf(bg/monetization): reuse PaymentSession when link added#1046

Merged
sidvishnoi merged 11 commits into
mainfrom
reuse-payment-session
May 2, 2025
Merged

perf(bg/monetization): reuse PaymentSession when link added#1046
sidvishnoi merged 11 commits into
mainfrom
reuse-payment-session

Conversation

@sidvishnoi
Copy link
Copy Markdown
Member

@sidvishnoi sidvishnoi commented May 1, 2025

Context

Part of #976
The goal is to efficiently find the minSendAmount for a PaymentSession.

Changes proposed in this pull request

Reuse PaymentSession instead of starting a new one.

Original PR summary
  • In the first commit (e4a8ae5), it won't have the desired effect, as we have an AbortSignal that makes the probing restart.
  • In the next commit (c5de59f), we replace adjustAmount(rate) with findMinSendAmount() (which is independent of rate). Extracted into 1048.
  • When a new link tag is added, we want to keep using older minSendAmount, even if the adjustAmount may change due to splits. adjustAmount resulting rate is >= minSendAmount, so it makes sense to find minSendAmount first, and not find it ever again.
    • Currency fluctuations can change this minSendAmount in future, but then we'd need to probe/findMinSendAmount again (existing bug, will fix some time later).

Also updated the constructor type for PaymentSession a bit. Moved to #1047. I was thinking of adding a static PaymentSession.from(), but we don't need it right now. The new constructor format will help there as well.


Before (see quotes requests increasing as link tags added to page, including for existing tags):

Screen.Recording.2025-05-01.at.19.13.12.mov

After (see quotes requests for link tags already added are skipped; fewer requests):

Screen.Recording.2025-05-01.at.19.09.40.mov

@github-actions github-actions Bot added the area: background Improvements or additions to extension background script label May 1, 2025
@sidvishnoi sidvishnoi requested a review from DarianM May 1, 2025 12:09
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2025

Extension builds preview

Name Link
Latest commit 2c41549
Latest job logs Run #14794196175
Chrome (990.12KB)Download
Firefox (990.14KB)Download

@sidvishnoi sidvishnoi removed the request for review from DarianM May 1, 2025 12:15
@sidvishnoi sidvishnoi marked this pull request as draft May 1, 2025 12:15
Copy link
Copy Markdown
Member Author

@sidvishnoi sidvishnoi left a comment

Choose a reason for hiding this comment

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

test-e2e
Edit: Unrelated tests fail (wallet budget, flaky), so all good.

@sidvishnoi sidvishnoi marked this pull request as draft May 2, 2025 10:17
@sidvishnoi sidvishnoi removed the request for review from DarianM May 2, 2025 10:17
@sidvishnoi sidvishnoi marked this pull request as ready for review May 2, 2025 11:19
@sidvishnoi sidvishnoi requested a review from DarianM May 2, 2025 11:19
@sidvishnoi sidvishnoi merged commit 021f06f into main May 2, 2025
9 checks passed
@sidvishnoi sidvishnoi deleted the reuse-payment-session branch May 2, 2025 11:52
@sidvishnoi sidvishnoi linked an issue May 2, 2025 that may be closed by this pull request
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: background Improvements or additions to extension background script

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Payment streams overhaul

2 participants