Skip to content

fix(wasm): recover msg_gateway errCode when WebSocket dial fails - #1114

Open
csc-EricWu wants to merge 6 commits into
openimsdk:mainfrom
csc-EricWu:fix-wasm-ws-handshake-errcode
Open

csc-EricWu wants to merge 6 commits into
openimsdk:mainfrom
csc-EricWu:fix-wasm-ws-handshake-errcode

Conversation

@csc-EricWu

Copy link
Copy Markdown

Browser WebSocket upgrades do not expose the HTTP error body, so WASM clients only saw NetworkError 10000 for token failures like 1507. Probe the handshake URL over HTTP and pass the real errCode to OnConnectFailed.

🅰 Please add the issue ID after "Fixes #"

Fixes #
H5 使用 @openim/wasm-client-sdk(底层为 openim-sdk-core 编译的 WASM)连接 msg_gateway 时,服务端因 token 无效返回 errCode: 1507 TokenNotExistError,但前端 OnConnectFailed 回调拿到的却是 errCode: 10000(NetworkError),导致业务无法按 token 类错误做退登,只能陷入「连接失败 → 重连」循环。

同一套服务端、同一 token,Flutter(原生 OpenIMCore)可以感知真实错误码;H5/WASM 侧错误码被吃掉。

Browser WebSocket upgrades do not expose the HTTP error body, so WASM
clients only saw NetworkError 10000 for token failures like 1507. Probe
the handshake URL over HTTP and pass the real errCode to OnConnectFailed.

Co-authored-by: Cursor <cursoragent@cursor.com>
@pull-request-size pull-request-size Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 24, 2026
Older wasm-client-sdk builds only pass operationID into APIs that now
expect a pagination req string; undefined becomes "<undefined>" and
breaks json.Unmarshal. Normalize null/undefined to "{}" in ReflectCall.

Co-authored-by: Cursor <cursoragent@cursor.com>
@pull-request-size pull-request-size Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 24, 2026
Shayetet and others added 4 commits August 1, 2026 13:16
主动登出原先 SendReqWaitResp 最长阻塞 20s;在 js/wasm(尤其 Safari)
上会卡死主线程甚至导致刷新无效。改为 SendReqNoWait 尽力通知服务端回收
推送 token,并在 Exit 后立即结束 writePump 的等待。

Co-authored-by: Cursor <cursoragent@cursor.com>
js/wasm 上 KickOnline 后若立刻 DispatchLogout(关库/关连接/initResources),
易与业务层页面跳转叠在一起卡死 Mobile Safari。改为仅回调 OnKickedOffline,
由页面硬跳卸载;并跳过踢线后的底层 websocket.Close,以及 IndexDB Worker close。

原生平台行为保持不变:OnKickedOffline 后仍 DispatchLogout。

Co-authored-by: Cursor <cursoragent@cursor.com>
通知里 versionID 为空会走全量成员同步并丢弃群资料;同步前回退路径先应用 ExtraData,并修正 ZDebug 参数不成对的日志错误。

Co-authored-by: Cursor <cursoragent@cursor.com>
按 seq 补洞时一次最多可拉 50 条,群通知等 payload 较大时 WebSocket 二进制回包在 Safari 上会被截断,导致 gob decode unexpected EOF、长连接断开。将单次请求拆成小批次(每批 8 个 seq),减小单帧体积。

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant