Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: ENOENT: no such file or directory, unlink #67

Closed
jangrewe opened this issue Sep 12, 2023 · 4 comments · Fixed by #68 or #69
Closed

Error: ENOENT: no such file or directory, unlink #67

jangrewe opened this issue Sep 12, 2023 · 4 comments · Fixed by #68 or #69
Assignees
Labels
bug Something isn't working

Comments

@jangrewe
Copy link

Describe the bug
We're running smtp-relay in Docker on an EC2 instance, and the container regularly crash with this error (but varying filenames, of course):

Sep 12 07:17:10 gitlab docker[1603915]: node:fs:1883
Sep 12 07:17:10 gitlab docker[1603915]:   handleErrorFromBinding(ctx);
Sep 12 07:17:10 gitlab docker[1603915]:   ^
Sep 12 07:17:10 gitlab docker[1603915]: Error: ENOENT: no such file or directory, unlink '.email_20230912T071709979Z.eml'
Sep 12 07:17:10 gitlab docker[1603915]:     at Module.unlinkSync (node:fs:1883:3)
Sep 12 07:17:10 gitlab docker[1603915]:     at PassThrough.<anonymous> (file:///smtp-relay/lib/server.js:188:20)
Sep 12 07:17:10 gitlab docker[1603915]:     at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
Sep 12 07:17:10 gitlab docker[1603915]:   errno: -2,
Sep 12 07:17:10 gitlab docker[1603915]:   syscall: 'unlink',
Sep 12 07:17:10 gitlab docker[1603915]:   code: 'ENOENT',
Sep 12 07:17:10 gitlab docker[1603915]:   path: '.email_20230912T071709979Z.eml'
Sep 12 07:17:10 gitlab docker[1603915]: }
Sep 12 07:17:10 gitlab docker[1603915]: Node.js v18.17.1

The majority of mail it accepts gets handled without any issues, but this happens every once in a while (e.g. twice in 12 hours now).

To Reproduce
Steps to reproduce the behavior:

  1. run smtp-relay
  2. send mails (in our case from GitLab, but i don't think this matters)
  3. See error

Expected behavior
Emails get relayed and the container keeps running.

@jangrewe jangrewe added the bug Something isn't working label Sep 12, 2023
@loopingz
Copy link
Owner

The only unlink used in the server code is here:

    // @ts-ignore
    stream.on("end", async () => {
      await this.filter("Data", session, [session]);
      session.email = await simpleParser(fs.createReadStream(session.emailPath));
      await this.onDataRead(session);
      if (!this.config.keepCache) {
        fs.unlinkSync(session.emailPath);
      }
      callback();
    });

I'm still unsure why it cannot delete it, I will update code to have a try/catch around the unlink today, in the mean time you can try to add a keepCache: true to your configuration

@loopingz loopingz self-assigned this Sep 12, 2023
@jangrewe
Copy link
Author

Thanks, i've added this to the config and will keep an eye on the log and any updates. 😃

@loopingz
Copy link
Owner

The 1.3.3 version should not have the issue, please keep me update, and if you like the project please star it. It helps with visibility

@jangrewe
Copy link
Author

Thank you! I've just deployed the updated image and now i'm waiting for the first error (without crash), but i'm confident that your changes will be doing what they're supposed to. 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants