Repository navigation
platform-crossgram: 同一会话的发送按发起顺序落库 - #21
Open
std-external wants to merge 2 commits into
Open
std-external wants to merge 2 commits into
std-external wants to merge 2 commits into
Conversation
added 2 commits
November 20, 2026 15:44
带媒体的发送要先传完字节才发出送消息请求,一批并发发起时落库顺序变成上传完成顺序:带图的那条总排到最后,相邻纯文本也可能互相插队。给每个会话串一条发送队列,发起顺序即 QQ 的落库顺序。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
群友(Anillc,QQ 群反馈)从 patched 客户端往一个 QQ 群连发几条消息时,QQ 里看到的顺序会乱:一条带图的消息稳定跑到整批的最后,相邻两条纯文本也会偶尔对调。用「不带来源的转发」把这一批再转发一次,卡片里就复制了同样的乱序。
原因
QQ 的房间顺序就是落库顺序,而这条链路没有会话内的发送顺序保证:
Dialogs.sendMessage只按randomId去重,多条messages.sendMessage各自独立执行;QQNTPlatform.sendMessage也没有队列;QQNTClient.sendMessage:带媒体的消息先把字节传完(preflight + Highway 上传)才 POST/messages,纯文本几乎立刻落库。于是并发发起的一批消息按「上传完成顺序」落库:带图的那条必然最后到,文本之间也会按调度顺序插队。
修复
QQNTPlatform给每个会话串一条发送队列(queueConversationSend):同会话的发送按发起顺序执行,队尾结算后清掉对应表项。copyForwardedMessages走的是同一个sendMessage,因此也一并被串起来。验证
platform.test.ts「lands a burst of sends in issue order even when the media one uploads first」:并发发一条 text+image+text 和一条纯文本,断言 QQ 侧收到的顺序是 image 先、text 后。去掉修复时该用例失败(收到 text 先),加上后通过。vitest run packages/platform-crossgram/src --exclude '**/*.e2e.test.ts':339 passed / 1 skipped;唯一失败的 suite 是voice-worker-composition.integration.test.ts,原因是本机没有cargo(环境问题,与本次改动无关)。vitest.mtproto-e2e.config.mts需要完整构建)。关联
crossgram-project/qqnt-bridge的 PR「forward: 合并转发按原生 seq 兜底排序」——即使调用方顺序仍乱,卡片也按 QQ 的msgSeq排版。来源:QQ 群内反馈(报告人 Anillc)。