šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Book a DemoInstallSign in
Socket

get-stack-trace

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-stack-trace

V8 stack traces with optional source map resolution.

2.0.3
Source
npm
Version published
Weekly downloads
79K
6.79%
Maintainers
1
Weekly downloads
Ā 
Created
Source

get-stack-trace

Travis build status Coveralls NPM version Canonical Code Style Twitter Follow

V8 stack traces with optional source map resolution.

Motivation

A lot of NPM packages are transpiled either using Babel or TypeScript.

This means that if you attempt to resolve a CallSite using Error.prepareStackTrace and Error.captureStackTrace, the resulting CallSite object will reference the tranpiled file, rather than the original source file. However, if the project was distributed with source maps, then we can use the available source maps to resolve the original CallSite.

In practise, this is useful if the intent is to log the stack trace of an application at a particular time in execution, e.g. Slonik creates a stack trace prior to every asynchronous call for debugging purposes.

For the stack traces to resolve, packages must be distributed with a source map file along with the transpiled file, e.g. such as in the case of this project:

$ cd ./dist && tree .
.
ā”œā”€ā”€ index.js
ā”œā”€ā”€ index.js.flow
ā”œā”€ā”€ index.js.map
ā”œā”€ā”€ test.js
ā”œā”€ā”€ test.js.flow
ā”œā”€ā”€ test.js.map
ā”œā”€ā”€ types.js
ā”œā”€ā”€ types.js.flow
└── types.js.map

Usage

import {
  getStackTrace
} from 'get-stack-trace';

const stackTrace = await getStackTrace();

Keywords

stack trace

FAQs

Package last updated on 21 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts