Fix source mapping of zero-column locations #248
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?:
Fixes an issue with source maps not being applied correctly when multiple calls to the same function occur within the same line.
In Node.js v25+ time profiles with lineNumber enabled will use the new column field in the LineTick type to correlate with the correct entry in the source map file. In prior versions it will match against the first call to a same-named function in the line for which mapping is being attempted.
This means all calls after the first in a line will be correctly attributed in Node.js v25+ and will become a best-guess of the first match in any older versions.
It also fixes a smaller bug that functions in a bundle could be mapped incorrectly if they share a same name but only different source files.
Motivation:
Currently if two calls to the same function occur within the same line they are undifferentiated. The way the logic works presently will result in the first call being mapped to the first mapping and the second call left unmapped.
How to test the change?:
Try profiling a source-mapped fibonacci function. You'll see the leaf node, where it's slightly more costly to do the second return expression call than the first, is left unmapped.