simon300000 / bilibili-live-ws

Bilibili live WebSocket/tcp API
MIT License
316 stars 31 forks source link

Bug: `Buffer` 未定义 #388

Open excing opened 1 year ago

excing commented 1 year ago

调用 LiveWS 类出现 Uncaught (in promise) ReferenceError: Buffer is not defined 的错误,代码位置如下(ws.ts#22):

ws.onmessage = isNode ? ({ data }) => this.emit('message', data) : async ({ data }) => this.emit('message', Buffer.from(await new Response(data as unknown as InstanceType<typeof Blob>).arrayBuffer()))

请问这是什么问题呢?是我的配置错误吗?怎么解决?

谢谢。

simon300000 commented 1 year ago

是在用浏览器吗?

excing commented 1 year ago

嗯,是的。

simon300000 commented 1 year ago

我整了一个ws.js的补丁,可能要麻烦在node_modules里面手动替换文件帮忙测试一下,因为我也不知道这个是否可以修复这个问题,如果可以的话我就发一个新版本 ws.js.zip

excing commented 1 year ago

这个我要怎么用呢?ws.js 文件很多报错。

image

simon300000 commented 1 year ago

这个报错你不用管,你看你的项目文件,里面应该有这个 node_modules/bilibili-live-ws/src/ws.js 把这个ws.js替换掉

excing commented 1 year ago

替换好了,但重新运行项目,查看浏览器开发者工具,ws.js 还是之前的代码,没有被替换。

simon300000 commented 1 year ago

我去 怎么会这样呢 这个进入玄学领域了

excing commented 1 year ago

[笑哭] node_modules 目录里的文件可以直接更新替换吗?

simon300000 commented 1 year ago

哎 难道不行吗 我直接发新版本好了

simon300000 commented 1 year ago

bilibili-live-ws@6.2.2

excing commented 1 year ago

谢谢,错误没有了,非常感谢~

simon300000 commented 1 year ago

9c39556e-aaee-11e4-9caf-bd06630b03d2 png

simon300000 commented 1 year ago

github网页开着其实会自动刷新的(Simon在 08.05.2023,上午10:16,Qiang @.***> 写道: [比心]为什么你的回复能这么快[惊]

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>