问题描述
我通过HTTP / 2编码了一些简单的SSE。符合我的期望。它定期将一些数据从服务器传送到客户端。
但是当我看到浏览器的开发控制台时,我发现了一些可怕的东西,
Picture of Resource is increasing
随着时间的流逝,资源量正在增加。 (我认为这是由于SSE的数据流所致。)
问题:
- 这正常吗?
- 如何清除消耗的SSE流?没必要吗?
这是代码;
// Client
#listenSSE () {
this.#sse = new EventSource('/_SSE/' + this.clientUID)
this.#sse.onmessage = (event) => {
const parsed = JSON.parse(event.data)
console.log(parsed) // doing some job with SSE event.
}
this.#sse.onerror = (error) => {
console.error('SSE error',error)
this.#sse.close()
this.#sse = null
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)