Node.js:EBADF,错误文件描述符
如果我重新加载我的应用程序(使用重新加载按钮从浏览器)很多次,例如50次重新加载/10秒
,它会给我这个错误:
events.js:45
throw arguments[1]; // Unhandled 'error' event
^
Error: EBADF, Bad file descriptor
在我看来,这就像带宽错误或类似的东西,最初,当我使用 HTML 5 Audio API 播放时,我遇到了错误,如果我按顺序加载音频文件 10-15 次,那么我就会收到错误,但现在我发现我收到错误,但没有音频 API 也只需重新加载即可该网站很多次,而且 Safari 给我的错误速度比 Chrome 快得多(WTF?)
我正在使用 Node.js 0.4.8 和 express
+ jade
和我还使用 db-mysql 模块连接到 MySQL 数据库。
我在网上找不到任何关于这个主题的文章有什么帮助,所以请让我知道什么会导致这个错误,因为它真的很令人困惑:(
If I reload my application (from the browser with the reload button) a lots of times like 50 reload/10 seconds
it gives me this error:
events.js:45
throw arguments[1]; // Unhandled 'error' event
^
Error: EBADF, Bad file descriptor
This seems to me like a bandwidth error or something like that, originally I've got the error when I played with the HTML 5 Audio API, and If I loaded the audio file 10-15 times sequentially then I've got the error, but now I've discovered that I get the error without the Audio API too just by reloading the site a lots of times, also Safari gives me the error much faster than Chrome (WTF?)
I'm using Node.js 0.4.8 with express
+ jade
and I'm also connected to a MySQL database with the db-mysql
module.
I can't find any articles on the web about this topic what helps, so pleeease let me know what can cause this error because it's really confusing :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
“重新加载应用程序”是指从浏览器刷新应用程序的主页,还是实际停止并重新启动 Node.js 服务器进程?我假设是前者,在这种情况下,如果您无法可靠地重现这一点,那么调试将非常棘手,特别是因为您没有良好的堆栈跟踪来查明源代码。但是如果您使用express.js
app.error
挂钩(此处的文档< /a>)您需要记录“错误文件描述符”错误的错误路径,这应该可以提示您这是一个被删除的临时文件还是什么。就实际原因而言,我们只能提供猜测,因为“错误文件描述符”是一个非常通用的低级错误,基本上意味着您正在对不再处于正确状态的文件描述符调用操作来处理该操作(例如读取已关闭的文件、打开已删除的文件等)。By "reload your application" do you mean refresh your app's home page from a browser, or actually stop and restart the node.js server process? I assume the former, in which case if you can't reliably reproduce this it will be pretty tricky to debug, especially since you don't have a good stack trace to pinpoint the source. But if you use the express.js
app.error
hook (docs here) you'll want to log the error path from the "Bad file descriptor" error, which should hopefully clue you in to whether this is a temporary file that got deleted or what. In terms of the actual cause, we can only offer guesses since "Bad file descriptor" is a very generic low level error that basically means you are calling an operation on a file descriptor that is no longer in the correct state to handle that operation (like reading a closed file, opening a file that has been deleted, etc).@CIRK,看看这个: https://github.com/joyent/node/issues/第1189章
不是节点问题,而是系统调优问题。
编辑:或者可能与 connect 1.4.3 中的此错误有关:
https://github.com/senchalabs/connect/issues/297
(如果这是您的)这种情况,尝试升级一下
@CIRK, take a look at this: https://github.com/joyent/node/issues/1189
it's not a node problem, but a system tuning issue.
edit: or maybe it's related to this error in connect 1.4.3:
https://github.com/senchalabs/connect/issues/297
if this is your case, just try to upgrade it
此错误可能是由于使用
fs
保存名称为数字而不是字符串的文件而导致的。文件名必须是字符串:错误:
正确:
也正确:
This error may result from using
fs
to save a file whose name is a number rather than a string. File names must be strings:Incorrect:
Correct:
Also correct: