Skip to content

Failed downloads strand filesystem resources (addons, locale) #301

Description

@koopatroopa

Two spots allocate a filesystem resource then run a download that can throw, with no cleanup on the failure path - the same shape as the install() temp-dir leak in #300, but with a worse symptom: the leftover is later treated as valid.

addons.ts - empty addon dir read as installed

maybeDownloadAddons (src/addons.ts:88-94) does fs.mkdirSync(addonPath) then downloadAndExtract, which can throw. The catch only logs, so the empty dir persists. The existsSync(addonPath) guard at the top of the loop then treats it as installed on the next run, pushes it to the addon list, and the addon silently never loads.

A fix needs care: addDefaultAddons runs on every launch(), not just camoufox fetch. Just removing the dir on failure makes a persistently-failing addon URL re-download (webdl's 5x/5s retry = ~25s stall) on every launch, and the cleanup itself must be guarded so it can't throw and break the launch.

locale.ts - truncated GeoIP DB used as valid

downloadMMDB (src/locale.ts:198-199) streams straight into the live MMDB_FILE path. A download that throws mid-stream leaves a truncated file, and getGeolocation only checks existsSync(MMDB_FILE) (locale.ts:213), so the partial DB is opened as valid. A temp-file + rename-on-success fixes it, but the temp name should be randomised - a fixed ${MMDB_FILE}.download collides if two launches sharing an INSTALL_DIR download concurrently.

Happy to send PRs for both if useful - flagging them together since they share the root cause with #300.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    t-toolingIssues with this label are in the ownership of the tooling team.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions