Skip to content

Report missing source maps in profile comments#298

Open
szegedi wants to merge 4 commits intomainfrom
szegedi/report-unmapped
Open

Report missing source maps in profile comments#298
szegedi wants to merge 4 commits intomainfrom
szegedi/report-unmapped

Conversation

@szegedi
Copy link

@szegedi szegedi commented Mar 11, 2026

(This builds on #292.)

Rationale

In the backend, we want to better identify profiles that might require server-side unminification because their source maps were not present locally in the application. We will depend on customers emitting generated/minified sources with the sourceMappingURL annotation present, but I think that's fair; most modern tools will add it by default and users must go out of their way to set a flag for the annotation to not be emitted. If we don't support server-side unminification for those, I think that's fine. We'll have to document it like that once when we roll out the feature.

I expect rolling this out will massively reduce the number of profile candidates for server-side unminification.

Summary

  • Tracks JS files that declare a sourceMappingURL annotation but for which no map file is found after both phases of source map discovery
  • SourceMapper.mappingInfo() returns missingMapFile: true on the SourceLocation for such files
  • serialize() in the profile serializer emits a single dd:has-missing-map-files token into profile.comment when at least one such file is encountered during serialization

Details

Only files that declare a sourceMappingURL are flagged — files with no annotation that simply have no map are not reported. A file resolved via the .map-file fallback (Phase 2) is not flagged even if its annotation pointed to a missing path.

The token approach (single well-known string in comment) keeps profile size impact minimal: the string is only added to the string table when needed, and no per-path data is emitted.

Test plan

  • SourceMapper unit tests: missingMapFile=true set when annotation declares missing map, not set for plain files or files resolved via fallback
  • serialize() tests: token emitted for both serializeTimeProfile and serializeHeapProfile, not emitted when no source mapper is used or when all maps are resolved

🤖 Generated with Claude Code

Jira: PROF-13985

@pr-commenter
Copy link

pr-commenter bot commented Mar 11, 2026

Benchmarks

Benchmark execution time: 2026-03-13 10:24:53

Comparing candidate commit 69692ee in PR branch szegedi/report-unmapped with baseline commit 6ab3e39 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 87 metrics, 33 unstable metrics.

@szegedi szegedi added the semver-minor Usually minor non-breaking improvements label Mar 11, 2026
@github-actions
Copy link

github-actions bot commented Mar 11, 2026

Overall package size

Self size: 2.05 MB
Deduped: 2.41 MB
No deduping: 2.41 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | source-map | 0.7.6 | 185.63 kB | 185.63 kB | | pprof-format | 2.2.1 | 163.06 kB | 163.06 kB | | node-gyp-build | 3.9.0 | 8.81 kB | 8.81 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@szegedi szegedi force-pushed the szegedi/report-unmapped branch from f55cf32 to b7c7986 Compare March 12, 2026 14:41
Base automatically changed from lazy-sourcemapper to main March 12, 2026 15:07
szegedi and others added 4 commits March 13, 2026 11:19
…le comments

When a JS file has a sourceMappingURL annotation but no map file is found
after both phases of directory scanning, the file path is tracked in
SourceMapper.declaredMissingMap. mappingInfo() for such files returns a
SourceLocation with missingMapFile: true.

In serialize(), unique paths with missingMapFile: true are collected and
emitted into profile.comment as pairs of string IDs:
  [dedup("dd:missing-map-file-for"), dedup(filePath)]

This uses the otherwise-unused comment section and avoids bloating the
string table since paths are already present via Function.filename.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers serializeTimeProfile and serializeHeapProfile emitting
dd:missing-map-file-for comment pairs, no comments without a source
mapper or when all maps are resolved, and deduplication of paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ath pairs

Replace the per-path comment pairs with a single well-known token in the
profile comment section. This is sufficient to signal that at least one
file referenced in the profile locations declared a sourceMappingURL but
no map was found, without bloating the profile with individual paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@szegedi szegedi force-pushed the szegedi/report-unmapped branch from b7c7986 to 69692ee Compare March 13, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver-minor Usually minor non-breaking improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant