]> git.giacomolli.uk - onechat/commit
Keep the connection of a new WhatsApp link
authorAnderson A. Giacomolli <agiacomolli@gmail.com>
Sun, 8 Nov 2026 17:50:26 +0000 (14:50 -0300)
committerAnderson A. Giacomolli <agiacomolli@gmail.com>
Sun, 8 Nov 2026 17:50:26 +0000 (14:50 -0300)
commita85d214071706753f358f0af23cfd525c28dbfe0
treea32c75cca5ca17cd1fd6dd998fae7b8067e1f2bb
parentf2e67d5579593e2d4f1cb2d9165b851c52a06715
Keep the connection of a new WhatsApp link

After a pairing, the linked device never connected again. The pairing
client connected with the context of the pairing, and the library keeps
the context of ConnectContext for its keep-alive loop, its event handler
loop, and its reconnections. After PairSuccess the server ends the
stream and the library connects again with that context, but the end of
the pairing canceled it, so the reconnection stopped. The session got no
prekeys, no Signal sessions, and no contacts, and no message came.

The pairing client now connects with the context of Run, which lives
until the daemon stops, as the connection at the start of the daemon
does. The context of the pairing still limits the QR channel, the wait
for the code, and the wait for the link, and a pairing that does not
link disconnects its client.

The fake client keeps the context of each connection, and the pairing
test checks that the context stays alive after the link. The test fails
without the fix.

Issue: 6f69ca1
whatsapp.go
whatsapp_fake_helper_test.go
whatsapp_test.go