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

dynamic import breaks line numbers in stack traces #404

Closed
4 of 5 tasks
neelance opened this issue Nov 22, 2023 · 5 comments · Fixed by #406
Closed
4 of 5 tasks

dynamic import breaks line numbers in stack traces #404

neelance opened this issue Nov 22, 2023 · 5 comments · Fixed by #406
Labels
bug Something isn't working outdated pending triage

Comments

@neelance
Copy link

neelance commented Nov 22, 2023

Precheck

  • I searched existing issues before opening this one to avoid duplicates
  • I'm able to reproduce this issue and prove it with a minimal reproduction
  • I understand this is not a place to ask for free debugging support

Problem

This code reports a stack trace with broken line numbers:

async function main(): Promise<void> {
  console.log(1);
  console.log(2);
  console.log(3);

  throw new Error("HERE");

  await import("some-import-statment");
}

main().catch(console.error);

The broken stack trace:

Error: HERE
    at main (.../index.ts:1:188)
    at <anonymous> (.../index.ts:9:1)
    at ModuleJob.run (node:internal/modules/esm/module_job:217:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async loadESM (node:internal/process/esm_loader:34:7)
    at async handleMainPromise (node:internal/modules/run_main:66:12)

Expected behavior

With the import line commented out the stack trace is correct:

Error: HERE
    at main (.../index.ts:6:9)
    at <anonymous> (.../index.ts:11:1)
    at ModuleJob.run (node:internal/modules/esm/module_job:217:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async loadESM (node:internal/process/esm_loader:34:7)
    at async handleMainPromise (node:internal/modules/run_main:66:12)

Minimal reproduction URL

See above.

Version

v4.2.0

Node.js version

v20.9.0

Package manager

npm

Operating system

macOS

Contributions

  • I plan to open a pull request for this issue
  • I plan to make a financial contribution to this project (sponsoring via @afilio-de)
@privatenumber
Copy link
Owner

Thank you for the issue and sponsorship! Fix will be released shortly

@neelance
Copy link
Author

Thanks for fixing!

It seems like there is still some bad information in my tsx cache. How can I clear it?

@privatenumber
Copy link
Owner

Oops I shoudlve handled this in the cache key. Will fix that shortly.

@privatenumber
Copy link
Owner

@neelance
Copy link
Author

Works! 👍

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working outdated pending triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants