Skip to content

0.22: reduce the core app-source downloader’s Undici footprint #4674

Open

Description

@thymikee

Reduce the default install size under #4591 while retaining the existing app-source download contract. The current package report shows a 518,980-byte undici.js. The packed importers are Limrun’s SDK tunnel code and the provision-kit downloader. Limrun (#3311) and Maestro keep their plugin-owned dependencies.

  • Trace requestApprovedUrl and measure a narrower maintained transport against the current bundle. Compare an upstream entry or existing Node APIs before considering a vendored subset. If vendoring wins, account for the license, upstream version and update ownership.
  • Preserve the existing streaming response and cleanup interface, approved-address pinning, TLS hostname verification, scoped proxy/NO_PROXY, redirect validation, header handling, byte limits, cancellation and error behavior. Keep downloader tests intact and verify the actual packed public path.
  • Compare equivalently prepared core tarballs and fresh installed footprints, including dependencies. Record unpacked and download bytes plus package/module attribution. Proceed with implementation only when a material saving and contract parity are demonstrated.

Source and test inventory can start independently. Final size attribution requires the Limrun branch or merged #3311 so its dependency is outside the measured core.

Activity

  1. added this to the 0.22 - lean core milestone on Nov 18, 2026
  2. apex-sentinel-staging commented on Nov 18, 2026

    @apex-sentinel-staging

    Apex Sentinel · Issue review

    Suggested label: feature

    The issue requests a new optimization: shrinking the default Undici footprint for the core app-source downloader while preserving existing download behavior. It provides a concrete target file size, affected importers, and explicit verification steps, so a maintainer could act on it.

  3. thymikee commented on Nov 18, 2026

    @thymikee
    MemberAuthor

    Current state: the static bundle probe confirms the 518,980-byte shipped Undici chunk is shared by Limrun and the core app-source downloader. Deep Undici imports still bundled roughly 308 kB in the probe and rely on internal entrypoints. A supported Node HTTP transport is the next candidate. Apex is characterizing the existing behavior with loopback tests before trying a local replacement. Preserve pinned address and TLS identity, both HTTP and HTTPS CONNECT, scoped proxy rules, existing timeout behavior, and cancellation and socket cleanup. Keep the original transport if matching it requires a larger or less maintainable implementation. The provisional saving is approximately 0.5 MB unpacked after #3311. A matched pack comparison is still required.

  4. thymikee commented on Nov 20, 2026

    @thymikee
    MemberAuthor

    Decision on the error contract for the Node HTTP(S) downloader:

    • Keep COMMAND_FAILED with details.networkErrorCode. Node system codes pass through unchanged (ECONNRESET, ECONNREFUSED, ENOTFOUND, ETIMEDOUT, TLS codes).
    • Timeouts get transport-independent codes owned by agent-device: connect-timeout, header-timeout, body-timeout. No Undici-specific code (UND_ERR_*) stays in the contract.
    • Caller cancellation stays a separate outcome and never reports a timeout code.
    • A failure before headers and a failure while the body streams report the same field. The body path also removes the partial file, as today.

    Acceptance: tests for each code before headers and during the body through the download command, and the matched package size comparison.

    Order: after the Limrun extraction (#3311) removes the other Undici consumer from core, so the size comparison measures the real saving.

  5. thymikee commented on Nov 20, 2026

    @thymikee
    MemberAuthor

    Status: not started in this round. Decision recorded earlier: keep details.networkErrorCode; Node codes pass through; agent-device timeout codes are connect-timeout, header-timeout, body-timeout; cancellation is separate. It is sequenced after the Limrun extraction (#4846) merges.

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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions