mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-06-13 04:31:16 +00:00
sendMessage resolves with the temporary message ID inside a .then() microtask. If TDLib emits updateMessageSendSucceeded synchronously (cached file, already-known media), the event handler fires while tempMsgId is still null — the success is dropped and the promise hangs until the 15-min upload timeout fires. Buffer success/failure events that arrive before tempMsgId is known, then replay them in the .then() callback once tempMsgId is set. Extract completeWithSuccess / completeWithFailure helpers so the resolution path is shared between live events and replayed events. This race matters more now that stalls fail fast — without the buffer, a fast-completing upload could still hang for 15 min before recovery. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>