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

Bug: Buffer 未定义 #388

Open
excing opened this issue May 8, 2023 · 13 comments
Open

Bug: Buffer 未定义 #388

excing opened this issue May 8, 2023 · 13 comments

Comments

@excing
Copy link

excing commented May 8, 2023

调用 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
Copy link
Owner

是在用浏览器吗?

@excing
Copy link
Author

excing commented May 8, 2023

嗯,是的。

@simon300000
Copy link
Owner

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

@excing
Copy link
Author

excing commented May 8, 2023

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

image

@simon300000
Copy link
Owner

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

@excing
Copy link
Author

excing commented May 8, 2023

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

@simon300000
Copy link
Owner

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

@excing
Copy link
Author

excing commented May 8, 2023

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

@simon300000
Copy link
Owner

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

@simon300000
Copy link
Owner

[email protected]

@excing
Copy link
Author

excing commented May 8, 2023

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

@simon300000
Copy link
Owner

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

@simon300000
Copy link
Owner

simon300000 commented May 10, 2023 via email

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