Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken sourcemap in the stack trace of uncaught errors #447

Closed
4 of 6 tasks
unleashy opened this issue Dec 27, 2023 · 5 comments
Closed
4 of 6 tasks

Broken sourcemap in the stack trace of uncaught errors #447

unleashy opened this issue Dec 27, 2023 · 5 comments
Labels

Comments

@unleashy
Copy link

unleashy commented Dec 27, 2023

Acknowledgements

  • I searched existing issues before opening this one to avoid duplicates
  • I understand this is not a place for seek help, but to report a bug
  • I understand that the bug must be proven first with a minimal reproduction
  • I will be polite, respectful, and considerate of people's time and effort

Minimal reproduction URL

https://gist.github.com/unleashy/6b0956eb7572cafbf0eb5f18c9c491a4

Version

v4.7.0

Node.js version

v20.10.0

Package manager

N/A

Operating system

Windows

Problem & Expected behavior

Run npx tsx foo.ts with the code from the gist:

file:///C:/Programming/js/foo.ts:1
let foo="foo";throw new Error("foo");
                    ^

Error: foo
    at <anonymous> (c:\Programming\js\foo.ts:4:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async loadESM (node:internal/process/esm_loader:34:7)
    at async handleMainPromise (node:internal/modules/run_main:113:12)

Node.js v20.10.0

Basically if an uncaught error is displayed, as per normal node procedure the line of the code where the error was thrown is shown, in the original sourcemap. However tsx dumps the whole contents of the file, minified, into the console. For small files, as in the reproduction, I guess this is fine? But for big files the console gets utterly spammed with completely useless minified code. Curiously, the file paths are correct.

I couldn't get to reproduce this on Stackblitz… so I'm guessing this is some sort of Windows problem? But it doesn't happen with ts-node.

I tested with npm and yarn and both had the same result. And whatever is in tsconfig.json seems to make no difference.

The expected behaviour for me would be for the code displayed in the error trace to only show the line of the affected code, source-mapped to the original Typescript.

Contributions

  • I plan to open a pull request for this issue
  • I plan to make a financial contribution to this project
@unleashy unleashy added bug Something isn't working pending triage labels Dec 27, 2023
@unleashy unleashy changed the title Broken sourcemap for uncaught error stacks Broken sourcemap in the stack trace of uncaught errors Dec 27, 2023
@wydengyre

This comment was marked as duplicate.

@wydengyre
Copy link

@unleashy Not just a Windows problem. Same bug for me on MacOS (14.3.1).

@privatenumber
Copy link
Owner

Thanks for reporting—happy to accept a PR to fix this!

Locking thread to direct further dialogue in the form of PRs.

Repository owner locked and limited conversation to collaborators Feb 28, 2024
Repository owner unlocked this conversation Apr 4, 2024
@privatenumber
Copy link
Owner

@wydengyre

I believe you were experiencing #478 which was fixed in v4.7.2
I'm guessing most people stumbling across this thread may be confusing this with that too.

@unleashy

Your problem is happening in Node v20.10.0, which means it's not related to #478

I don't have a Windows but it works fine for me on Mac.
Can you provide a reproduction via GitHub Actions CI using a Windows OS?

@privatenumber
Copy link
Owner

Closing as a reproduction was not provided

@privatenumber privatenumber closed this as not planned Won't fix, can't repro, duplicate, stale May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants