Stack traces and diagnostics name a module by its real path
Date: 2026-11-29
Area: modules, errors
Supersedes: ADR 0199's "Diagnostics and stack traces
keep the spelling the module was first loaded under"; ADR 0199's other decisions stand.
Related: Module Resolution, Errors,
#2252
Context
ADR 0199 (#2252) made import.meta.url, import.meta.resolve and a module's relative imports use the file's real
path, so a module reached through a symlink names its target there, as in Node. Its stack frames, its uncaught
error's location (-->, --output=json's fileName), its parse error and its link errors still named the spelling
the module was first loaded under. Which spelling that was depended on which import reached the module first, and it
disagreed with the module's own import.meta.url: a link's name pointed at a file that is not the one whose code ran.
Node resolves symlinks for the modules it loads and names the real file in every frame. Johannes decided on 2026-11-29 to show the real path by default ("Agreed"), and asked for an option that hides file paths for deployed and sandboxed environments, which is a separate decision.
Decision
A host file module's code is compiled under its real path, the address its record already resolves from
(DiagnosticPathOf in Goccia.Modules): source modules, bytecode modules and their parse and link errors alike. Stack
frames, the uncaught error's location and code frame, and the JSON envelope's fileName therefore name the real file,
whichever spelling loaded the module first.
The entry keeps the name it was run under, whether the host provided its source or its bytecode: the spelling the user
or host gave the run, with symlinks kept (a host may make it absolute). It is a module the host named, not one the
program reached. Node canonicalizes its entry too unless --preserve-symlinks-main is given; that is not decided here.
Virtual modules and a Script's imports keep their addresses, and a file whose real path a virtual module's address
claims keeps its own spelling, so one name never stands for two modules. Sandbox mode, which has no host paths to
canonicalize, is unchanged.
Consequences
- A frame, a diagnostic and
import.meta.urlof the same module agree, and match Node for imported modules. - On macOS a module under a temporary directory is named under
/private/var/...rather than/var/..., and on Windows by its long name rather than an 8.3 short name, asimport.meta.urlalready is. - An error message that names the import request itself, such as
Cannot load bytecode module '<path>', keeps the path as requested. - Hiding file paths in diagnostics is not decided here.