Skip to content

Incorrect stack traces when using ts-node/register and swc in production #2165

Description

@samsternatmiter

I am not quite sure how to report this issue, but basically in production (in Sentry, specifically) we are getting stack traces that make no sense after the first frame. They point to lines of code which are real but could njot possibly be part of the error trace (ex: pointing to an enum definition, etc).

I am curious if there is some missing flag we need to set to get source mapping / stack traces working properly when using ts-node/register alongside swc

This is how we run our app in production:

node -r ts-node/register -r tsconfig-paths/register --max-old-space-size=5000 app.ts

We have the following config in our tsconfig.json:

  "ts-node": {
    "swc": true,
    "transpileOnly": true,
    "compilerOptions": {
      "module": "CommonJS",
      "moduleResolution": "Node"
    }
  },

And this is our .swcrc:

{
  "sourceMaps": true,
  "module": {
    "type": "commonjs",
    "strictMode": true,
    "noInterop": false
  },
  "jsc": {
    "externalHelpers": false,
    "target": "es2015",
    "parser": {
      "syntax": "typescript",
      "tsx": true,
      "decorators": false,
      "dynamicImport": true
    },
    "transform": {
      "legacyDecorator": true,
      "decoratorMetadata": false,
      "react": {
        "throwIfNamespace": false,
        "useBuiltins": false,
        "pragma": "React.createElement",
        "pragmaFrag": "React.Fragment",
        "importSource": "react",
        "runtime": "automatic"
      }
    },
    "keepClassNames": false,
    "paths": {
      [REDACTED]
    },
    "baseUrl": ".."
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions