Skip to content

Fix rpc-error due to quick transaction lookup#1159

Merged
spacebear21 merged 1 commit intopayjoin:masterfrom
zealsham:rpc-cli-error
Oct 24, 2025
Merged

Fix rpc-error due to quick transaction lookup#1159
spacebear21 merged 1 commit intopayjoin:masterfrom
zealsham:rpc-cli-error

Conversation

@zealsham
Copy link
Collaborator

@zealsham zealsham commented Oct 9, 2025

This pr addresses an error that occurs due to rpc client looking up the transaction right before it's on chain . Error: Transient error: Implementation error: Obtained failure status(500): Internal Server Error

The delay introduced allows the transaction to broadcasted on chain before the lookup

This closes #1154

Pull Request Checklist

Please confirm the following before requesting review:

@zealsham zealsham closed this Oct 9, 2025
@zealsham zealsham reopened this Oct 9, 2025
@spacebear21
Copy link
Collaborator

Is this issue reproducible in the e2e tests? It would be nice to add an assertion that fails before this patch and succeeds with the patch - otherwise this timeout will get removed by someone else in a few months when we've forgotten why it was added.

@zealsham
Copy link
Collaborator Author

zealsham commented Oct 9, 2025

The time delay is making the test take forever as it blocks the entire tokio runtime . i'll figure out a diff approach

@DanGould
Copy link
Contributor

DanGould commented Oct 9, 2025

"By default, the ZeroMQ feature is automatically compiled in if the necessary prerequisites are found" Are the necessary prereqs typically found? Waiting for an event is definitely the 'right' way to do this, but a much shorter timeout, even a function that polls on a much shorter timeout, would also be a hack I'm ok with merging.

@coveralls
Copy link
Collaborator

coveralls commented Oct 9, 2025

Pull Request Test Coverage Report for Build 18781657652

Details

  • 22 of 32 (68.75%) changed or added relevant lines in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.04%) to 83.698%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin-cli/src/app/v2/mod.rs 22 32 68.75%
Files with Coverage Reduction New Missed Lines %
payjoin/src/core/receive/v2/mod.rs 2 90.84%
Totals Coverage Status
Change from base Build 18761146827: -0.04%
Covered Lines: 8990
Relevant Lines: 10741

💛 - Coveralls

Copy link
Contributor

@DanGould DanGould left a comment

Choose a reason for hiding this comment

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

A single timeout is gonna be too flaky and take a long time. IMO what you want is a separate method that loops on a small delay (~200ms) between making calls, and times out after looping for a longer time (~10s) and the timeout produces an error. A little polling code complexity will make a far more robust call for various platforms.

@zealsham
Copy link
Collaborator Author

Is this issue reproducible in the e2e tests? It would be nice to add an assertion that fails before this patch and succeeds with the patch - otherwise this timeout will get removed by someone else in a few months when we've forgotten why it was added.

i've pondered on this and haven't been able to figure out how to trigger this in e2e

Copy link
Collaborator

@spacebear21 spacebear21 left a comment

Choose a reason for hiding this comment

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

The quick-lookup error only occurs when the receiver is not interrupted prior to monitoring. In the e2e test, the receiver is interrupted then resumed after the sender has processed the payjoin tx. I think we should be able to reproduce the error in a e2e test that does not interrupt and resume the receiver and does a synchronous payjoin.

Comment on lines 746 to 754
// Check if we've exceeded the wait time
// since the payment will eventually come through, wondering if i should just remove this check
if start.elapsed() >= timeout_duration {
return Err(anyhow!(
"Timeout waiting for payment confirmation after {:?}",
timeout_duration
));
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

This check is necessary in a production implementation because the payment is not guaranteed to come through if the sender doesn't broadcast it. Instead of erroring out completely we could e.g. prompt the user on whether they want to broadcast the fallback transaction, or wait longer for the payjoin transaction. However we could do this in a follow-up PR after this bug is fixed.


match result {
Ok(_) => {
println!("Payment confirmed!");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
println!("Payment confirmed!");
println!("Payjoin transaction {txid} detected in the mempool!");

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will a simple "payjoin transaction detected in the mempool" work ? , getting the txid outside checkpayment function scope will need changes to the api , making private fields public

This pr addresses an error that occurs due to rpc client
looking up the transaction right before it's on chain .
Error: Transient error: Implementation error: Obtained failure status(500): Internal Server Error

The delay introduced allows the transaction to broadcasted on chain before the lookup

fix format issue

fix long pooling test

Implement pooling mechanism for transaction check

Implement pooling mechanism for transaction check

fix rpc error

fix rpc error

fix lint error
Copy link
Collaborator

@spacebear21 spacebear21 left a comment

Choose a reason for hiding this comment

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

tACK dc9c4f4

Copy link
Collaborator

@spacebear21 spacebear21 left a comment

Choose a reason for hiding this comment

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

tACK dc9c4f4

Comment on lines +773 to +774
// keep polling

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: unnecessary lines

@spacebear21 spacebear21 dismissed DanGould’s stale review October 24, 2025 15:11

addressed feedback

@spacebear21 spacebear21 merged commit 0284a9d into payjoin:master Oct 24, 2025
10 checks passed
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.

payjoin-cli receiver returns a 500 error after a successful payjoin.

4 participants