NODEJS代码尝试FS操作的堆栈跟踪
同事遇到了一个奇怪的问题,即他们的容器化应用程序在降低的特权下运行,有时会在创业公司崩溃,而神秘的eperm:不允许操作,打开
操作。有些东西试图在node_modules
下写入文件(node_modules/winston/lib/winston.js
准确地说)。该文件存在,但仅具有读取权限。可悲的是,这是间歇性的,我无法在本地繁殖。鉴于Winston
是一个受欢迎的日志记录库,我忍不住在这里发挥了恶意软件。
有没有办法找到失败的FS写入尝试的来源?例如,我很想看到堆栈痕迹。我们已经尝试了node_debug = fs
,但这不会输出其他信息。
完整,仅在流程退出之前输出:
Error: EPERM: operation not permitted, open '/src/node_modules/winston/lib/winston.js'
Code: EPERM
A co-worker has encountered a strange issue where their containerized app, which is running under lowered privileges, sometimes crashes at startup with a mysterious EPERM: operation not permitted, open
operation. Something is trying to write to a file under node_modules
(node_modules/winston/lib/winston.js
to be exact). That file exists but only with read permissions. Sadly this is intermittent, and I cannot reproduce locally. Given that winston
is a popular logging library, I can't help but suspect malware is at play here.
Is there a way to find the source of failed FS write attempts? I would love to see a stack trace, for example. We've already tried NODE_DEBUG=fs
, but that outputs no additional information.
Full and only output before the process exits:
Error: EPERM: operation not permitted, open '/src/node_modules/winston/lib/winston.js'
Code: EPERM
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过使用
debug =*
环境变量,我们能够获得错误的堆栈跟踪。这只是一个常规的旧require(...)
引起此引起的调用。我们怀疑这可能是托管基础架构/容器/其他内容的错误,但是如果您遇到这样的神秘问题,则一般而言debug =*
很有帮助。By using the
DEBUG=*
environment variable, we were able to get a stack trace for the error. It's just a regular oldrequire(...)
call causing this. We suspect this is probably a bug with the hosting infrastructure/containers/whatever, but in generalDEBUG=*
helps a lot if you're experiencing mysterious issues like this.