Skip to content

onError 未触发,业务错误响应只能走 onClosed,建议增加响应体支持 #89

Description

@songdansyz

🧩 问题描述

当服务端返回业务错误(如未登录,code=40100),响应为 HTTP 200,但返回内容是 JSON 错误体(非 SSE 格式)。当前情况下:

  • onMessage 不触发
  • onError 也不触发
  • onClosed 被回调,但拿不到任何 response body 或状态码

这导致我们在客户端无法判断为何连接被关闭,也无法给用户弹出提示(比如"未登录,请重新登录")。


🔁 重现步骤

  1. 使用 EventSource 连接接口
  2. 服务端返回如下内容:
{
  "code": 40100,
  "success": false,
  "message": "请登录后再操作"
}
3.客户端只走了 onClosed(),没有触发 onError

期望
希望在 onError(error) 中能收到 HTTP 错误响应内容(包括 statusCode 和 body)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions