Skip to content

Commit e63f1a4

Browse files
authored
Merge pull request #1506 from lightninglabs/rfq-timeout-flake
rfq: store outgoing request before sending message
2 parents 5225722 + c1d3b28 commit e63f1a4

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

.github/workflows/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ env:
2121

2222
GO_VERSION: '1.23.6'
2323

24-
LITD_ITEST_BRANCH: 'script-key-migrations'
24+
LITD_ITEST_BRANCH: 'master'
2525

2626
jobs:
2727
#######################

rfq/stream.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,12 @@ func (h *StreamHandler) HandleOutgoingMessage(
154154
ctx, cancel := h.WithCtxQuitNoTimeout()
155155
defer cancel()
156156

157-
err = h.cfg.PeerMessenger.SendCustomMessage(ctx, lndClientCustomMsg)
158-
if err != nil {
159-
return fmt.Errorf("unable to send message to peer: %w",
160-
err)
161-
}
162-
163-
// Store outgoing requests.
157+
// We store the outgoing request in the request map, so we can interpret
158+
// any response and map it to the original request. We do this before
159+
// sending the message, because otherwise we could potentially receive
160+
// the response while we're waiting for the atomic lock to be released,
161+
// which would lead to us not knowing about the request in the first
162+
// place, and we couldn't map the response.
164163
switch msg := outgoingMsg.(type) {
165164
case *rfqmsg.BuyRequest:
166165
h.outgoingRequests.Store(msg.ID, msg)
@@ -173,6 +172,12 @@ func (h *StreamHandler) HandleOutgoingMessage(
173172
msg.ID.String())
174173
}
175174

175+
err = h.cfg.PeerMessenger.SendCustomMessage(ctx, lndClientCustomMsg)
176+
if err != nil {
177+
return fmt.Errorf("unable to send message to peer: %w",
178+
err)
179+
}
180+
176181
return nil
177182
}
178183

0 commit comments

Comments
 (0)