log-process-errors

Show some ❤️ to Node.js process errors

APACHE-2.0 License

Downloads
548.3K
Stars
467
Committers
4

Bot releases are hidden (Show)

log-process-errors - v12.0.0 Latest Release

Published by ehmicky 12 months ago

Breaking changes

  • Minimal supported Node.js version is now 18.18.0
log-process-errors - v11.0.1

Published by ehmicky over 1 year ago

Dependencies

  • Upgrade internal dependencies
log-process-errors - v11.0.0

Published by ehmicky over 1 year ago

Breaking changes

  • Minimal supported Node.js version is now 16.17.0
log-process-errors - Release 10.2.0

Published by ehmicky almost 2 years ago

Features

  • Improve tree-shaking support
log-process-errors - Release 10.1.1

Published by ehmicky about 2 years ago

Internal

  • Add more tests
log-process-errors - Release 10.1.0

Published by ehmicky about 2 years ago

Features

log-process-errors - Release 10.0.0

Published by ehmicky about 2 years ago

Package size

The npm package size has been reduced by 98%, from 4500kB to 87kB.

Custom logic

The log option was renamed to onError. Its arguments are (originalError, event) instead of (error, level, originalError).

The process error event is now passed as a second argument instead of being set as error.name. Its case is not capitalized anymore, to match the event name in Node.js.

Before:

logProcessErrors({
  log(error) {
    if (error.name === 'UncaughtException') {
      console.error(error)
    }
  },
})

After:

logProcessErrors({
  onError(error, event) {
    if (event === 'uncaughtException') {
      console.error(error)
    }
  },
})

Pretty-printing

Errors are not pretty-printed anymore. As a consequence, the colors option was removed too. The onError option can be used instead to customize how the errors are printed.

Filtering

The levels option was removed. The onError option can be used for filtering.

Before:

logProcessErrors({
  levels: {
    warning: 'silent',
  },
})

After:

logProcessErrors({
  onError(error, event) {
    if (event !== 'warning') {
      console.error(error)
    }
  },
})

Testing option

The testing option was removed. The onError option can be used instead.

Before:

logProcessErrors({ testing: 'ava' })

After:

logProcessErrors({
  // Throw the `error` to make the unit test fail while letting other tests run
  onError(error) {
    throw error
  },
})

Process exit

The exitOn option was changed from an array of strings to a simpler boolean. It was also renamed exit.

The exit is still graceful, i.e. it waits for ongoing tasks to complete, up to 3 seconds. However, if there are none, the process now exits immediately.

Before:

logProcessErrors({ exitOn: [] })

After:

logProcessErrors({ exit: false })

Compatibility with other libraries

If other libraries (such as Winston, Bugsnag, etc.) are also listening for process events, they might also try to exit the process. This created conflicts with this library. This has been fixed by making the exit option default to false when process events listeners already exist.

Bug fixes

  • Fix support for --unhandled-rejections=strict
  • Do not crash when error.stack is undefined or null
  • Support cross-realm errors

TypeScript

TypeScript types have been simplified.

Internal

Added 100% test coverage.

log-process-errors - Release 9.4.0

Published by ehmicky about 2 years ago

Features

  • Reduce npm package size
log-process-errors - Release 9.3.0

Published by ehmicky about 2 years ago

Documentation

log-process-errors - Release 9.2.0

Published by ehmicky about 2 years ago

Features

  • Reduce npm package size
log-process-errors - Release 9.1.0

Published by ehmicky over 2 years ago

Features

  • Add TypeScript types
log-process-errors - Release 9.0.0

Published by ehmicky over 2 years ago

Breaking changes

  • Minimal supported Node.js version is now 14.18.0
log-process-errors - Release 8.0.0

Published by ehmicky over 2 years ago

Breaking changes

  • multipleResolves has been deprecated by Node.js. Therefore, support for it has been removed.
    • If your code uses the level or exitOn option with a multipleResolves parameter, you should remove it.
    • Otherwise, this release is not a breaking change for you.
log-process-errors - Release 7.0.1

Published by ehmicky over 3 years ago

Bug fixes

  • Fix main field in package.json
log-process-errors - Release 7.0.0

Published by ehmicky over 3 years ago

Breaking changes

Features

  • Improve colors detection
log-process-errors - Release 6.3.0

Published by ehmicky over 3 years ago

Features

  • Improve colors on Windows terminal
log-process-errors - Release 6.2.0

Published by ehmicky almost 4 years ago

Features

  • The exitOn() option now defaults to ['uncaughtException', 'unhandledRejection'] on Node >= 15.0.0. Its default
    value is still ['uncaughtException'] on Node < 15.0.0. This is to mimic Node.js default behavior: since Node 15.0.0, processes exit on unhandled promises.
log-process-errors - Release 5.1.2 (backport)

Published by ehmicky over 4 years ago

Dependency

  • Remove unused dependency core-js
log-process-errors - Release 6.1.1

Published by ehmicky over 4 years ago

Bug fixes

  • Fix handling uncaught exceptions or warnings that are not Error instances (#32)
log-process-errors - Release 5.1.1 (backport)

Published by ehmicky over 4 years ago

Bug fixes

  • Fix handling uncaught exceptions or warnings that are not Error instances (#32)
Package Rankings
Top 1.97% on Npmjs.org
Badges
Extracted from project README
Node TypeScript Codecov Mastodon Medium