Skip to content

Conversation

@amackillop
Copy link
Contributor

The receive_payment function would exit based solely on time thresholds, even when PaymentClaimable events were pending. This caused payments to get stuck if the node shut down after receiving the HTLC but before claim_funds() completed.

Track pending claims using a HashSet and wait for PaymentReceived or PaymentFailed events before allowing shutdown. Add a 60-second hard timeout with warning to prevent infinite blocking.

The receive_payment function would exit based solely on time
thresholds, even when PaymentClaimable events were pending. This
caused payments to get stuck if the node shut down after receiving
the HTLC but before claim_funds() completed.

Track pending claims using a HashSet and wait for PaymentReceived
or PaymentFailed events before allowing shutdown. Add a 60-second
hard timeout with warning to prevent infinite blocking.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c8f2d05bea

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +477 to +481
// Hard timeout to prevent infinite wait
if total_time_elapsed >= HARD_TIMEOUT_MS {
if !pending_claims.is_empty() {
eprintln!(
"[lightning-js] WARNING: Exiting receive_payment with {} pending claims after hard timeout ({}ms): {:?}",

Choose a reason for hiding this comment

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

P2 Badge Honor caller thresholds before hard timeout

This hard-timeout check is unconditional, so receive_payment will break after 60s even when min_threshold_ms/quiet_threshold_ms are larger and there are no pending claims. That changes the API’s timing semantics: callers that pass a larger minimum (e.g., to wait a few minutes for incoming payments) now return early at 60s and can miss later events. Consider applying the hard timeout only when pending_claims is non-empty or making it max(min_threshold_ms, HARD_TIMEOUT_MS).

Useful? React with 👍 / 👎.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not ideal but it's unreasonable to pass in a larger threshold right now as it sets a floor on payment confirmation time. The hard timeout already only applies when pending claims is non empty

wit-bindgen 0.50+ requires Rust edition 2024 which is not available
in Cargo 1.82.0. Pin to versions below 0.50 to keep CI building.
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.

2 participants