Node.js:EBADF,错误的文件描述符 [英] Node.js : EBADF, Bad file descriptor

查看:231
本文介绍了Node.js:EBADF,错误的文件描述符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果像50 reload/10 seconds一样多次(从浏览器中使用重新加载"按钮重新加载我的应用程序),则会出现此错误:

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

在我看来,这似乎是带宽错误或类似的错误,最初当我使用HTML 5 Audio API播放时遇到了错误,如果我依次加载音频文件10至15次,则说明错误,但是现在我发现,即使通过多次重新加载网站也没有音频API也会出现错误,而且Safari给我的错误要比Chrome(WTF?)快得多

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?)

我在express + jade上使用Node.js 0.4.8,并且还通过db-mysql模块连接到MySQL数据库.

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 :(

推荐答案

通过重新加载应用程序"是指从浏览器刷新应用程序的主页,还是实际上停止并重新启动node.js服务器进程?我假设是前者,在这种情况下,如果您不能可靠地重现它,则调试起来将非常棘手,尤其是因为您没有很好的堆栈跟踪来精确定位源代码.但是,如果您使用express.js app.error挂钩(此处的文档),您会希望从错误文件描述符"错误中记录错误路径,希望它可以帮助您了解这是一个已删除的临时文件还是什么.就实际原因而言,我们只能提供猜测,因为错误的文件描述符"是一个非常普通的低级错误,它基本上意味着您正在对文件描述符调用一个操作,该操作不再处于正确的状态以处理该操作(例如读取已关闭的文件,打开已删除的文件等).

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).

这篇关于Node.js:EBADF,错误的文件描述符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆