Version
v24.15.0
Also reproduced on v23.6.0.
Platform
macOS 15.6 (Darwin 24.6.0), x86_64
Subsystem
util, source_map
What steps will reproduce the bug?
Create these two files in the same directory.
repro.js:
const{getCallSites}=require("node:util");function foo(){console.log(getCallSites(1,{sourceMap:!0})[0].functionName)}foo();
//# sourceMappingURL=repro.js.map
repro.js.map:
{
"version": 3,
"sources": ["original.js"],
"sourcesContent": ["const { getCallSites } = require('node:util'); function foo() { console.log(getCallSites(1, { sourceMap: true })[0].functionName); } foo();"],
"mappings": "AAAA,KAAM,CAAE,YAAa,EAAI,QAAQ,WAAW,EAAG,SAAS,KAAM,CAAE,QAAQ,IAAI,aAAa,EAAG,CAAE,UAAW,EAAK,CAAC,EAAE,CAAC,EAAE,YAAY,CAAG,CAAE,IAAI",
"names": []
}
How often does it reproduce? Is there a required condition?
It reproduces every time on v23.6.0 and v24.15.0.
The source map must map the call-site location without providing a corresponding name entry. Source Map v3 permits an empty names array.
What is the expected behavior? Why is that the expected behavior?
The command should print:
The generated V8 call site contains foo as its function name. Remapping its source location should preserve that name when the source map does not provide a replacement.
This is also consistent with Node.js's source-mapped stack trace formatter, which retains the generated function name when no mapped name exists.
What do you see instead?
The command prints an empty line because:
getCallSites(1, { sourceMap: true })[0].functionName === ''
Additional information
Running the same file without source-map remapping prints the expected name:
reconstructCallSite() in lib/util.js currently assigns:
functionName: entry.name ?? ''
Consequently, an absent optional source-map name replaces the generated V8 function name with an empty string. It should instead fall back to the generated call site's functionName.
Version
v24.15.0
Also reproduced on v23.6.0.
Platform
Subsystem
util, source_map
What steps will reproduce the bug?
Create these two files in the same directory.
repro.js:repro.js.map:{ "version": 3, "sources": ["original.js"], "sourcesContent": ["const { getCallSites } = require('node:util'); function foo() { console.log(getCallSites(1, { sourceMap: true })[0].functionName); } foo();"], "mappings": "AAAA,KAAM,CAAE,YAAa,EAAI,QAAQ,WAAW,EAAG,SAAS,KAAM,CAAE,QAAQ,IAAI,aAAa,EAAG,CAAE,UAAW,EAAK,CAAC,EAAE,CAAC,EAAE,YAAY,CAAG,CAAE,IAAI", "names": [] }How often does it reproduce? Is there a required condition?
It reproduces every time on v23.6.0 and v24.15.0.
The source map must map the call-site location without providing a corresponding name entry. Source Map v3 permits an empty
namesarray.What is the expected behavior? Why is that the expected behavior?
The command should print:
The generated V8 call site contains
fooas its function name. Remapping its source location should preserve that name when the source map does not provide a replacement.This is also consistent with Node.js's source-mapped stack trace formatter, which retains the generated function name when no mapped name exists.
What do you see instead?
The command prints an empty line because:
Additional information
Running the same file without source-map remapping prints the expected name:
reconstructCallSite()inlib/util.jscurrently assigns:Consequently, an absent optional source-map name replaces the generated V8 function name with an empty string. It should instead fall back to the generated call site's
functionName.