Skip to content

Conversation

legendecas
Copy link
Member

lib,src: refactor assert to load error source from memory

The source code is available from V8 API and assert can avoid reading
the source file from the filesystem and parse the file again.

lib: add source map support for assert messages

Map source lines in assert messages with cached source maps.

Fixes #59612

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Sep 3, 2025
@legendecas legendecas added assert Issues and PRs related to the assert subsystem. source maps Issues and PRs related to source map support. labels Sep 3, 2025
@BridgeAR BridgeAR self-requested a review September 3, 2025 21:37
legendecas and others added 2 commits September 3, 2025 23:35
The source code is available from V8 API and assert can avoid reading
the source file from the filesystem and parse the file again.
Map source lines in assert messages with cached source maps.
Copy link

codecov bot commented Sep 3, 2025

Codecov Report

❌ Patch coverage is 89.42308% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.92%. Comparing base (737b42e) to head (9e516a3).
⚠️ Report is 76 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/errors/error_source.js 90.30% 15 Missing and 1 partial ⚠️
src/node_errors.cc 78.57% 2 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #59751      +/-   ##
==========================================
- Coverage   89.95%   89.92%   -0.04%     
==========================================
  Files         667      668       +1     
  Lines      196776   196733      -43     
  Branches    38409    38391      -18     
==========================================
- Hits       177006   176908      -98     
- Misses      12198    12241      +43     
- Partials     7572     7584      +12     
Files with missing lines Coverage Δ
lib/internal/assert/utils.js 100.00% <100.00%> (+7.88%) ⬆️
lib/internal/source_map/prepare_stack_trace.js 96.05% <100.00%> (+0.17%) ⬆️
src/node_errors.cc 65.04% <78.57%> (+0.86%) ⬆️
lib/internal/errors/error_source.js 90.30% <90.30%> (ø)

... and 38 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@marco-ippolito marco-ippolito left a comment

Choose a reason for hiding this comment

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

Let's goo!

@marco-ippolito marco-ippolito added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 4, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 4, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@legendecas
Copy link
Member Author

@BridgeAR CI is green now. I noticed that you requested a review from yourself. Would you mind taking a look? Thank you!

@legendecas legendecas added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. labels Sep 11, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Sep 11, 2025
@nodejs-github-bot
Copy link
Collaborator

Landed in a2a77b2...f1b56d6

nodejs-github-bot pushed a commit that referenced this pull request Sep 11, 2025
The source code is available from V8 API and assert can avoid reading
the source file from the filesystem and parse the file again.

PR-URL: #59751
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
nodejs-github-bot pushed a commit that referenced this pull request Sep 11, 2025
Map source lines in assert messages with cached source maps.

PR-URL: #59751
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
@legendecas legendecas deleted the assert-error-source branch September 11, 2025 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assert Issues and PRs related to the assert subsystem. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. source maps Issues and PRs related to source map support.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Assertions yield incorrect message when source is transpiled by loader
3 participants