question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question - Current active file is not recreated after being deleted by a worker.

See original GitHub issue

I have this current setup for rotating-file-stream writing logs whenever a request comes in.

rotating-file-stream: 1.3.9, 1.4.1 node: v6.9.0, v10.4.0 (same as my windows) OS: Ubuntu 16.04

let filenameBase = 'some base file name'
let directory = 'directory'
function makeGenerator (lastIndex) {
    let logIndex = 0
    if (Util.isNumber(lastIndex)) {
      logIndex = lastIndex
    }

    return function generator (time, index) {
      logIndex++
      return _filenameBase + '-' + logIndex + '.log'
    }
  }

  let stream = rfs(makeGenerator(lastIndex), {
    size: '1M',
    interval: '1d',
    immutable: true,
    path: directory,
    mode: 0o777
  })

It works currently but if I remove the current active file filenameBase-logIndex.log, the log being written are not flushed out to the file (expecting it to be recreated - which is currently working in windows) and only creates a new file when it has rotated (the size being recorded maxes out or reaches the maxSize threshold).

Not receiving any errors/warnings during the process.

I don’t know if this is the current behavior but please advise.

Edit: Tried to create a PoC for the fs.createWriteStream writing entries and removing the file halfway does not throw any error on the stream and just keeps writing until stream.end() is called.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
icciccicommented, Jun 19, 2019

Hi @homiedopie ,

I prefer following a different road; there are currently three open issues on rotating-file-stream: this one, #36 and #37, and the other two are about problems on windows and macOS; I prefer to not add something else working only under linux.

I hope you can understand, iCC

1reaction
icciccicommented, Jun 19, 2019

Hi @homiedopie ,

actually a good log file writing tool should, for each line (or lines block) it receive to write, to open in append the logfile, to write the line (or lines block) and to close the logfile.

This is something which rotating-file-stream doesn’t do and will solve many other problems more the one reported.

I’ve just decided to change rotating-file-stream behavior to do this in order to make it something more close to a good log file writing tool, but it will require some time.

Thank you for made me open my eyes! iCC

Read more comments on GitHub >

github_iconTop Results From Across the Web

fs.createWriteStream does not recreate file when deleted ...
Question - Current active file is not recreated after being deleted by a worker. iccicci/rotating-file-stream#38.
Read more >
Logback does not recreate log file after file has been deleted
After the delete I notice that no new audit.log file is created when I call the logger application. It is only when I...
Read more >
Why is space not being freed from disk after deleting a file in ...
It simply means the copy of /oradata/DATAPRE/file.dbf that process 25575 has open on file descriptor 33 was deleted while this process was ...
Read more >
Files marked for deletion are preventing me from checking into ...
I tried for several days to fix it, including deleting all the tables out of the EDMX designer, then recreating them. But it...
Read more >
Amazon EKS troubleshooting - AWS Documentation
This chapter covers some common errors that you may see while using Amazon EKS and how to work around them. If you need...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found