Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught (in promise) AbortError: The user aborted a request. #91

Open
Syzblue opened this issue Dec 4, 2024 · 2 comments
Open

Uncaught (in promise) AbortError: The user aborted a request. #91

Syzblue opened this issue Dec 4, 2024 · 2 comments

Comments

@Syzblue
Copy link

Syzblue commented Dec 4, 2024

当终止链接时页面直接报错,无法catch

const abortController = new AbortController();
      fetchEventSource(`${baseServer}/polar//public/aiChat/chat`, {
        method: 'POST',
        signal: abortController.signal,
        headers: {
          'Content-Type': 'application/json; charset=UTF-8',
          user: Storage.getUid() || '',
          token: Storage.getToken() || '',
          domain: Storage.getDomain() || '',
          ticket: Storage.getTicket() || '',
          tenant: Storage.getTenant() || '',
          version: Storage.getV() || ''
        },
        body: JSON.stringify({ conversationId: conversationId, question: message }),
        async onmessage(msg) {
          // abortController.abort()
          console.log('Received:', msg.data); // 处理接收到的消息
        },
        onclose() {
          console.log("111111111111111111close")
          // abortController.abort()
        },
        onerror(err) {
          console.log(err);
          // abortController.abort()
        }
      }).then(result=>{
        console.log(result)
      }).catch(err => {
          console.error(err);
      })
@yk805
Copy link

yk805 commented Feb 19, 2025

你解决了吗?? 我也遇到了 我自己也没有手动去关闭连接,每次会话结束自己就弹出来了,有点奇怪

@Syzblue
Copy link
Author

Syzblue commented Feb 19, 2025

没解决,最后我换了个最原始方式实现的框架来搞得这个需求

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants