# long-traces

> Adds asynchronous stack traces to error objects.

Latest version **0.38.0** (published 2026-02-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install long-traces
pnpm add long-traces
yarn add long-traces
bun add long-traces
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.38.0 |
| Published | 2026-02-17 |
| First published | 2023-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | jawis |
| Keywords | development, stack, trace, long trace, error handling |

## Links

- npm: https://www.npmjs.com/package/long-traces
- Repository: https://github.com/wistoft/jawis
- Homepage: https://github.com/wistoft/jawis/tree/main/packages/long-traces#readme
- Issues: https://github.com/wistoft/jawis/issues
- npm.io page: https://npm.io/package/long-traces

## Dependencies (1)

- [@jawis/jab](https://npm.io/package/@jawis/jab.md) ^0.38.0

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 0.38.0 (latest) — 2026-02-17
- 5.0.0-dev (dev) — 2025-07-25
- 0.0.1-dev.2 — 2023-09-28
- 0.0.1 — 2023-07-02

## README

# Long traces

Adds asynchronous stack traces to error objects.

The long stack is created lazily. The overhead of this module is only adding a
property to the error object, when it's thrown.

## Installation

```
npm i long-traces
```

## Usage

```js
import async_hooks from "async_hooks";
import { enable } from "long-traces";

enable(async_hooks);

// stack later in error handling

try {
  throw new Error("ups");
} catch (error) {
  //this is the stacks of all ancestors (i.e. excluding the errors own stack.)
  const longStack = error.getAncestorStackFrames();
}
```

## Known issues

- Relies on `__jawisNodeStack` set by jacs. So probably only works there.
- Has to monkey patch `Error` to get the stack when errors are thrown. This
  means the `instanceof` operator is not working properly. Might be fixable.
- Only works in node because browsers don't have the `async_hooks` API. This
  module would work in browsers with such an API available.

## Related work

- [longjohn](https://www.npmjs.com/package/longjohn)
- [trace](https://www.npmjs.com/package/trace)
- [stackup](https://www.npmjs.com/package/stackup)
- [long-stack-traces](https://www.npmjs.com/package/long-stack-traces)
- [superstack](https://www.npmjs.com/package/superstack)
- [double-stack](https://www.npmjs.com/package/double-stack)

[npmtrends.com](https://npmtrends.com/double-stack-vs-long-stack-traces-vs-longjohn-vs-stackup-vs-superstack-vs-trace)

Main inspiration is taken from
[trace](https://github.com/AndreasMadsen/trace/blob/master/trace.js) by
AndreasMadsen

## License

MIT

---
_Source: https://npm.io/package/long-traces · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
