Skip to content

Improve error messages with source lines #655

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

seveibar
Copy link
Contributor

@seveibar seveibar commented Jul 8, 2025

Summary

  • include original source line info when runtime errors occur
  • maintain source maps in execution context
  • annotate compiled code with sourceURL
  • add tests for execution error source lines

Testing

  • bun test tests/execution-error-line.test.tsx
  • bun test tests (fails: network-dependent tests)

https://chatgpt.com/codex/tasks/task_b_686499c3907c832eb2f9fdd7555b782b

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Incorrect Source Line Mapping in Error Messages

The addSourceLineToError function incorrectly uses a hardcoded offset of 6 (line - 6) when mapping stack trace line numbers to original source positions via source maps. The evalCompiledJs wrapper code adds only 4 lines before the compiled code, meaning the offset should be line - 4 to correctly align the stack trace line with the compiled code block. This arbitrary and brittle offset results in incorrect source line reporting in error messages.

lib/utils/addSourceLineToError.ts#L23-L24

const consumer = await new SourceMapConsumer(sourceMaps[path])
const pos = consumer.originalPositionFor({ line: line - 6, column: 0 })

Fix in CursorFix in Web


BugBot free trial expires on July 22, 2025
You have used $0.00 of your $50.00 spend limit so far. Manage your spend limit in the Cursor dashboard.

Was this report helpful? Give feedback by reacting with 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant