提问人:Ryan Roberts 提问时间:11/8/2023 更新时间:11/8/2023 访问量:31
使用 Bun/Node 在 Docker 容器中写入文件时出现“EBADF:文件描述符错误”
"EBADF: Bad file descriptor" when writing files within a Docker container with Bun/Node
问:
我在 docker 容器中托管一个简单的 Bun http 应用程序(使用普通 Node.js API 时仍然存在相同的问题,所以我认为它不是特定于 Bun 的),我正在尝试写入文件系统。
每次这样做时,我都会收到以下错误:
EBADF: Bad file descriptor
fd: "-2"
syscall: "write"
errno: -9
error: uploading initial file failed, unable to write: /usr/src/app/temp/<name-of-file>.gp5, EBADF: Bad file descriptor
这是代码 ->
const uploadPath = process.cwd() + `${this.tempFolder}/${Date.now()}__${file.name}`;
try {
await Bun.write(uploadPath, await file.arrayBuffer());
} catch (error) {
throw new Error(
`uploading initial file failed, unable to write: ${uploadPath}, ${error}`
);
}
和 路径还指向 Docker 文件资源管理器中文件夹的正确位置。process.cwd()
uploadPath
如果有人以前遇到过这个错误,请告诉我
答: 暂无答案
评论