Skip to content

Commit f77d4d7

Browse files
rustyrussellvincenzopalazzo
authored andcommitted
offers: fix flake in fetchinvoice.
In CI, this would sometimes fail: we would timeout waiting for the fetchinvoice reply. Never happened locally, so was annoying to debug. What happened was simple: we called injectonionmessage then when it returned, put the "sent" object in the linked list so we could recognize any reply onion messages. However, we were getting that reply before the plugin processed the response to injectonionmessage. This is possible because there are two fds for plugins: one for it to receive notifications and hooks (like onion messages) and one for normal RPC usage (like commands to inject onion messages). The fix is simple: put in the list *before* calling JSON RPC. Signed-off-by: Rusty Russell <[email protected]>
1 parent 2e06d81 commit f77d4d7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

plugins/fetchinvoice.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,6 @@ static struct command_result *sendonionmsg_done(struct command *cmd,
397397
tal_steal(cmd, plugin_timer(cmd->plugin,
398398
time_from_sec(sent->wait_timeout),
399399
timeout_sent_invreq, sent));
400-
sent->cmd = cmd;
401-
list_add_tail(&sent_list, &sent->list);
402-
tal_add_destructor(sent, destroy_sent);
403400
return command_still_pending(cmd);
404401
}
405402

@@ -513,6 +510,14 @@ static struct command_result *establish_path_done(struct command *cmd,
513510
sciddir_or_pubkey_from_scidd(&final_tlv->reply_path->first_node_id,
514511
sent->dev_path_use_scidd);
515512

513+
/* Put in list so we recognize reply onion message. Note: because
514+
* onion message notification comes from a different fd than the one
515+
* we send this command to, it can actually be processed *before* we
516+
* call done() */
517+
sent->cmd = cmd;
518+
list_add_tail(&sent_list, &sent->list);
519+
tal_add_destructor(sent, destroy_sent);
520+
516521
omsg = outgoing_onion_message(tmpctx, path, NULL, current_their_path(epaths), final_tlv);
517522
return inject_onionmessage(cmd, omsg, epaths->done, forward_error, sent);
518523
}

0 commit comments

Comments
 (0)