Skip to content

Problems with process.exit, e.g. on SIGTERM #67

@limikael

Description

@limikael

I have noticed that if I write something to the log, and then immediately do a process.exit();, then the line that was just logged will not be written.

I tried to close the writer first, using this function:

this.closeWriter = function() {

This function calls the end function on the stream. The end function is here:

https://nodejs.org/api/stream.html#stream_writable_end_chunk_encoding_callback

However, the end function is asynchronous which is why the data doesn't have time to be written. If it do a setTimeout and do the process.exit(); aftr some time (100ms) it works. But the isn't avery clean solution.

I would suggest to add a callback parameter to the closeWriter function that gets called when the stream is closed. If I would create a PR with such a function, would it be well received?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions