Skip to content

Error output may be truncated before the error message #24

Open

Description

@robinhouston

Many of the ndjson tools use error reporting code of the following sort – this example is from ndjson-split:

  try {
    sandbox.d = JSON.parse(line);
  } catch (error) {
    console.error("stdin:" + (i + 1));
    console.error(line);
    console.error("^");
    console.error("SyntaxError: " + error.message);
    process.exit(1);
  }

When processing something like GeoJSON, line may contain a substantial amount of data. In that case the process will exit before the output buffer has been fully printed, with the effect that the error output is truncated before the actual error message has been printed.

The documentation for process.exit warns that this can happen:

It is important to note that calling process.exit() will force the process to exit as quickly as possible even if there are still asynchronous operations pending that have not yet completed fully, including I/O operations to process.stdout and process.stderr.

Obviously not printing the error message makes debugging more difficult.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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