Skip to content
This repository was archived by the owner on Aug 11, 2022. It is now read-only.
This repository was archived by the owner on Aug 11, 2022. It is now read-only.

npm-debug.log should always be written when an error occurs #6350

@dylang

Description

@dylang

Current situation

Currently the npm-debug.log is stored in memory, and then dumped to disk when certain problems occur.

Problems

  1. Some errors don't cause a log to be generated, such as:

    npm ERR! cb() never called!
    npm ERR! not ok code 0
    
  2. Sometimes npm just hangs and there's no way to know what it was waiting for.

  3. When it fails it only writes out the last 10,000 lines because npmlog has a maxRecordSize of 10000. If it was streaming to disk this wouldn't be an issue. Note: I'm not a consumer of the logs so I'm not sure if the full log is necessary.

Proposed Solutions

Here's some ideas. Any of these might be enough to close this ticket.

  1. Fix the logic causing no long to be written with the above example, and auto-write a log file after some amount of time with no output to stdout to have a debug log for hang events.
  2. Write to the log file immediately (or asynchronously as long as an error won't prevent the last bits from being written.) On success unlink the log file.
  3. Introduce an option to force log file to be written no matter what.

Semi-related issue: #5214 npm report

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions