fix(gateway): support structured app-host messages - #48
Closed
gaoweifan wants to merge 1 commit into
Closed
Conversation
Owner
|
感谢PR!但目前主分支做了大量的改进,该PR有大量冲突,请解决完冲突并按新标准重新实现 :) |
gaoweifan
force-pushed
the
fix/app-host-object-messages
branch
from
September 2, 2026 11:52
3c9b116 to
a73a271
Compare
Author
|
上游仓库已经在commit 78ed0559(feat(compatibility): support structured app-host messages)中实现了相同的 AppHost 结构化消息兼容修复,并已合并到 main 分支。因此本 PR 的修改已经被上游实现覆盖,不再需要重复合并。 |
Owner
是的,目前已经支持新版。再次感谢你的贡献! |
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.
问题
在 ChatGPT Windows App 26.825.51511 上,OpenCodex 无法完成 AppHost RPC
注册,页面可能停留在 Codex 图标,并出现以下日志:
OpenCodex 现有 AppHost relay 只接受字符串或 null,因此会丢弃官方
MessagePort 发送的结构化对象。
根因
从本机安装的 ChatGPT Windows App 26.825.51511 官方 bundle 中可以确认,
AppHost transport 使用
structuredClonable编码,并直接通过 MessagePort发送值。其等价逻辑为:
在该模式下,普通对象、数组、BigInt、Date、undefined 和 byte view 等值会以
结构化数据通过 MessagePort,而不保证被预先转换为字符串。
修复前的 OpenCodex relay 对所有非字符串、非 null 数据只记录
non_string_message_from_official并直接丢弃,导致 AppHost RPC 请求无法继续,随后端口关闭并触发
MessagePort message error。修改内容
增加 AppHost RPC 的 JSON/WebSocket transport codec:
收紧 AppHost relay 生命周期:
对齐 MessagePort 关闭语义:
让 smart-scheduling、model-router presentation 和 token-usage 消费者同时接受
已解码的结构化 RPC 与旧版字符串 RPC,不改变现有协议路由和 UI 行为。
显式保留 WebSocket 入站的 100 MiB
maxPayload。该限制属于 WebSocket 网络边界,不是 codec 或 MessagePort 的消息限制。
兼容性
该 codec 仅用于在 AppHost MessagePort 与 JSON WebSocket 之间传输当前 RPC
实际使用的结构化值,并继续兼容旧版字符串和 null 帧。它不是通用的
structured-clone 实现,也不改变现有协议路由或 UI 行为。
验证
pnpm test:191/191 通过pnpm run build:gateway:通过node --check:通过git diff --check origin/main...HEAD:通过pnpm run launcher:pack:win:通过pnpm run launcher:dist:win:成功生成 Windows x64 NSIS 安装包和 ZIPMessagePort message error、non_string_message_from_official或 missing-relay 错误