NODEJS代码尝试FS操作的堆栈跟踪

发布于 2025-01-22 05:12:26 字数 507 浏览 2 评论 0原文

同事遇到了一个奇怪的问题,即他们的容器化应用程序在降低的特权下运行,有时会在创业公司崩溃,而神秘的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

懒的傷心 2025-01-29 05:12:26

通过使用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 old require(...) call causing this. We suspect this is probably a bug with the hosting infrastructure/containers/whatever, but in general DEBUG=* helps a lot if you're experiencing mysterious issues like this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文