Skip to content

Add crashlytics:sourcemap:upload command behind experiment#10565

Open
tonybaroneee wants to merge 39 commits into
mainfrom
crashlytics2
Open

Add crashlytics:sourcemap:upload command behind experiment#10565
tonybaroneee wants to merge 39 commits into
mainfrom
crashlytics2

Conversation

@tonybaroneee
Copy link
Copy Markdown
Contributor

Description

The crashlytics:sourcemap:upload command is a new Firebase CLI command that enables developers of web applications to upload JavaScript source maps to Firebase Crashlytics. This is essential for de-obfuscating JavaScript stack traces collected from web apps, allowing customers to view readable crash reports within the Crashlytics dashboard. This functionality is part of the larger effort to add support for web apps within Crashlytics.

Scenarios Tested

Unit + manually tested.

Sample Commands

firebase crashlytics:sourcemap:upload
--project <projectId>
--app-id <appID>
	--bucket-location <bucketLocation>
--app-version <appVersion>
[directory]

andrewbrook and others added 20 commits April 30, 2026 14:00
* Implement partial source map upload command

* lint

* move test fixture data

* improve coverage

* refactor

* format

* fix non-determinism in test
* Use git commit hash as default app version

* App version fallback hierarchy
* Update source map upload command options

- Remove `telemetryServerUrl` option
- Change mapping file positional argument from required to optional (defaults to root dir)

* Fix mapping path fallback and add test
* Handle mismatched source map file names

* Add start of line match

* Rename variable

* Refactor for readbility
* fix unit tests

* make resilient to test failures
* update sourcemap:upload to align with API

* cleanup

* lint

* lint
* misc bug fixes

* cleanup

* Lint fixes

* Mock auth in spec

* bypass requireauth hook in unit tests

---------

Co-authored-by: Anthony Barone <tonybaroneee@gmail.com>
@tonybaroneee tonybaroneee requested a review from joehan May 27, 2026 17:57
@wiz-9635d3485b
Copy link
Copy Markdown

wiz-9635d3485b Bot commented May 27, 2026

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings 5 Medium
Software Management Finding Software Management Findings -
Total 5 Medium

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new command crashlytics:sourcemap:upload to upload JavaScript source maps to Crashlytics for web apps, enabled under the crashlyticsWeb experiment flag. It includes the command implementation, utility functions for archiving files, and comprehensive unit tests. The code reviewer identified several critical issues, including a potential race condition and unhandled error crash in pipeAsync, a path resolution bug when using path.relative on already relative paths, a performance concern with reading entire JS files synchronously, a resource leak where temporary zip files are not deleted, and a missing retryDelay type definition in CommandOptions.

Comment thread src/archiveFile.ts
Comment thread src/commands/crashlytics-sourcemap-upload.ts Outdated
Comment thread src/commands/crashlytics-sourcemap-upload.ts Outdated
Comment thread src/commands/crashlytics-sourcemap-upload.ts Outdated
Comment thread src/commands/crashlytics-sourcemap-upload.ts Outdated
Comment thread src/commands/crashlytics-sourcemap-upload.ts
Comment thread src/commands/crashlytics-sourcemap-upload.ts Outdated
Comment thread src/commands/crashlytics-sourcemap-upload.ts Outdated
Comment thread src/commands/crashlytics-sourcemap-upload.ts Outdated
Comment thread src/commands/crashlytics-sourcemap-upload.ts Outdated
Comment thread package.json Outdated
@tonybaroneee tonybaroneee requested a review from joehan May 28, 2026 15:24
@tonybaroneee
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the crashlytics:sourcemap:upload command, allowing users to upload JavaScript source maps for web applications to Crashlytics under the crashlyticsWeb experiment flag. The implementation includes utilities for discovering source map mappings, extracting sourceMappingURL from JS files, and uploading zipped assets to Google Cloud Storage, alongside a new MurmurHash3 hashing function. The review feedback highlights a resource leak from an unclosed file descriptor in archiveFile.ts, a path resolution bug in uploadMap when options.projectRoot is customized, a potential buffer decoding issue in getLinkedSourceMapPath, and a style guide violation regarding explicit boolean comparisons.

Comment thread src/archiveFile.ts Outdated
Comment on lines +300 to +303
const obfuscatedPath = path
.relative(options.projectRoot ?? process.cwd(), obfuscatedFilePath)
.split(path.sep)
.map((p) => (p === ".next" ? "_next" : p))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

There is a bug here when options.projectRoot is specified and differs from process.cwd().

obfuscatedFilePath is already resolved as a relative path to rootDir (which is options.projectRoot ?? process.cwd()) in findSourceMapMappings. Calling path.relative(options.projectRoot ?? process.cwd(), obfuscatedFilePath) on an already relative path will cause Node's path.relative to resolve obfuscatedFilePath against process.cwd(), resulting in an incorrect path (e.g., containing ../../ segments).

Since obfuscatedFilePath is already relative to the project root, you should use it directly instead of calling path.relative again.

Suggested change
const obfuscatedPath = path
.relative(options.projectRoot ?? process.cwd(), obfuscatedFilePath)
.split(path.sep)
.map((p) => (p === ".next" ? "_next" : p))
const obfuscatedPath = obfuscatedFilePath
.split(path.sep)
.map((p) => (p === ".next" ? "_next" : p))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please double check this behavior by running the command from a subdirectory of a firebase project dir, and make sure that it still works as expected.

Comment thread src/crashlytics/sourcemap.ts Outdated
Comment thread src/crashlytics/sourcemap.ts Outdated
Copy link
Copy Markdown
Member

@joehan joehan left a comment

Choose a reason for hiding this comment

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

Mostly LGTM after a few final fixes!

Comment on lines +300 to +303
const obfuscatedPath = path
.relative(options.projectRoot ?? process.cwd(), obfuscatedFilePath)
.split(path.sep)
.map((p) => (p === ".next" ? "_next" : p))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please double check this behavior by running the command from a subdirectory of a firebase project dir, and make sure that it still works as expected.

Comment thread src/archiveFile.ts
Comment thread src/archiveFile.ts Outdated
Comment thread src/utils.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants