Skip to content

Conversation

FrederikBolding
Copy link
Member

@FrederikBolding FrederikBolding commented Oct 20, 2025

Description

Simplify the NPM fetching implementation to make it more readable, while also fixing a couple of issues:

  • Use the cache directory for the app instead of a shared directory
  • Re-use the cache key for the unpacked directory to allow for multiple installs at a time
  • Properly clean up files on the filesystem after install
  • Match error messages and states from the extension implementation

Changelog

CHANGELOG entry: null

Related issues

Closes: MetaMask/snaps#3617


Note

Refactors NPM tarball fetching with direct blob fetch, status/size validation, improved error handling, and robust cleanup; updates tests to match.

  • Core (NPM fetch):
    • Rewrite NpmLocation.fetchNpmTarball to use ReactNativeBlobUtil.config({ appendExt: 'tgz' }).fetch and RNTar.unTar.
    • Add response validation: assert 404 not-found, require 200 OK, enforce content-length against TARBALL_SIZE_SAFETY_LIMIT.
    • Improve errors using getErrorMessage; accept DetectSnapLocationOptions via constructor.
    • Ensure cleanup in finally: response.flush() and fs.unlink of unpacked path.
    • Read files as UTF-8 strings in readAndParseAt; remove stringToBytes.
    • Remove helpers: decompressFile, fetchAndStoreNPMPackage, cleanupFileSystem; drop SNAPS_NPM_LOG_TAG.
  • Tests:
    • Update mocks to include respInfo with status and content-length; adjust FS mocks; align with new fetch/untar flow.

Written by Cursor Bugbot for commit 46c1840. This will update automatically on new commits. Configure here.

@metamaskbot metamaskbot added the team-core-platform Core Platform team label Oct 20, 2025
@FrederikBolding FrederikBolding added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Oct 20, 2025
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Oct 20, 2025
@FrederikBolding FrederikBolding added the run-android-flask-e2e-smoke Run Android flask E2E tests on next CI run label Oct 20, 2025
@FrederikBolding FrederikBolding marked this pull request as ready for review October 20, 2025 14:49
@FrederikBolding FrederikBolding requested a review from a team as a code owner October 20, 2025 14:49
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Mrtenz
Mrtenz previously approved these changes Oct 21, 2025
Mrtenz
Mrtenz previously approved these changes Oct 21, 2025
@sonarqubecloud
Copy link

@FrederikBolding FrederikBolding added this pull request to the merge queue Oct 21, 2025
Merged via the queue into main with commit e4b17d7 Oct 21, 2025
84 of 85 checks passed
@FrederikBolding FrederikBolding deleted the fb/snaps-npm-refactor branch October 21, 2025 11:01
@github-actions github-actions bot locked and limited conversation to collaborators Oct 21, 2025
@metamaskbot metamaskbot added release-7.59.0 Issue or pull request that will be included in release 7.59.0 release-7.58.0 Issue or pull request that will be included in release 7.58.0 and removed release-7.59.0 Issue or pull request that will be included in release 7.59.0 labels Oct 21, 2025
@metamaskbot
Copy link
Collaborator

Missing release label release-7.58.0 on PR. Adding release label release-7.58.0 on PR and removing other release labels(release-7.59.0), as PR was added to branch 7.58.0 when release was cut.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed release-7.58.0 Issue or pull request that will be included in release 7.58.0 run-android-flask-e2e-smoke Run Android flask E2E tests on next CI run size-M team-core-platform Core Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review NPM installation implementation on mobile

3 participants