Coder Social home page Coder Social logo

get-stack-trace's Introduction

get-stack-trace

NPM version Canonical Code Style Twitter Follow

Stack traces as an array of stack frames with source maps support.

Usage

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

const stackTrace = getStackTrace();

serializeStackTrace('Error', 'Hello, World!', stackTrace);

get-stack-trace's People

Contributors

freshollie avatar gajus avatar jacobg213 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

get-stack-trace's Issues

The automated release is failing 🚨

🚨 The automated release from the main branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the main branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


No npm token specified.

An npm token must be created and set in the NPM_TOKEN environment variable on your CI environment.

Please make sure to create an npm token and to set it in the NPM_TOKEN environment variable on your CI environment. The token must allow to publish to the registry https://registry.npmjs.org/.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Compatibility with Node.js' built in source-map support

Hey @gajus came across this repo reading your comments on stack-trace.

We've recently been building out an experimental API for source-maps in Node.js itself. It's my goal to find some of the foundational libraries in the community that use prepareStackTrace, with the goal of potentially wiring in Node.js' built in source-map cache.

On my mind is stack-trace, express, winston, and bunyan.

Have any thoughts regarding a good approach ... I'm thinking if we could get some of your work in get-stack-trace upstreamed to stack-trace, it would help us support Winston.

Given your knowledge in the space, I'd also love your thoughts on how we'd add support to express (which overrides prepareStackTrace in depd), without stepping on the toes of bunyan/winston.

Non accessible file reads are not cached

TL;DR: Is there a reason for not caching fs.accessSync results during source map resolution? And original line number results from SourceMapConsumer?

Considering get-stack-trace is used by slonik every time an SQL query is made this library attempts to read the source files associated with the call and if they don't exist it will still attempt to read them next call anyway 🀯 .

Recently my team has tracked down a large amount of memory use being attributed to DataDog/dd-trace-js#913 (comment)

Digging deeper, it appears the cause is due to dd-tracer keeping track of all file reads, and because get-stack-trace is constantly trying to read files which don't exist DD is tracking these metrics and filling memory whilst it waits to send the metrics off. When we disabled the DD fs plugin our memory usage dropped significantly during intensive database tasks.

I can see a few improvements which could be made to solve these issues and improve performance of this library:

  1. Cache the results of isReadable: https://github.com/gajus/get-stack-trace/blob/master/src/resolveCallSiteSourceCodeLocation.js#L36
  2. Cache the original line number results of SourceMapConsumer: https://github.com/gajus/get-stack-trace/blob/master/src/resolveCallSiteSourceCodeLocation.js#L39

The results of both of these processes should remain static throughout execution, as we don't expect source files to change during execution.

  1. Optional, but is there any reason this library isn't using asynchronous file reads? It seems maddening to me that this library has an Asynchronous API, but chooses to use the synchronous file operations under the hood?

I'm happy to put in a PR to make these improvements.

Further details of what our memory ends up being filled with because of this:

image
image

Memory usage before disabling datadog fs plugin
image

Memory usage after disabling
image

Error while capturing Stack trace - Missing mappings.wasm

Current Behaviour

I am using slonik as a postgres-client to talk to my database. It is being used in 2 places -

  1. Inside a Graphql query which runs on serverless (lambda on aws).
  2. Directly fetching data from node cli scripts.

In the first scenario, I get an error message - ENOENT: no such file or directory, open '<PATH TO>/.esbuild/.build/src/handlers/mappings.wasm'. Which suggests that it is looking for that file in order to capture stack trace.

esbuild config in serverless -

  esbuild:
    loader:
      .graphql: text
      .html: text
    packager: npm
    bundle: true
    minify: true
    sourcemap: true
    keepNames: true
    concurrency: 8
    exclude:
      - pg-native

also the order for plugins in correct in serverless

In the second scenario, it works like a charm. I am able to talk to my db and also get the stack trace which is super helpful.

Possible Solution

Not sure about the possible solution but I can temporarily disable slonik to capture stack trace by setting captureStackTrace: false while creating pool.

Logs

Unable to produce a details log because captureStackTrace itself is throwing error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.