Skip to content

feat(http): the HTTP module loader core - #2

Merged
edusperoni merged 2 commits into
mainfrom
feat/http-loader-core
Dec 5, 2026
Merged

edusperoni merged 2 commits into
mainfrom
feat/http-loader-core

Conversation

@edusperoni

Copy link
Copy Markdown
Collaborator

Step 5 of the migration plan (docs/DESIGN.md §9): the HTTP module loader's policy and orchestration move into the core, behind a one-attempt transport seam. Both runtimes adopt it in follow-up PRs; nothing consumes it yet.

Changes users will see once the runtimes adopt it

  • Redirects are gated. A release build with security.remoteModuleAllowlist refuses a module whose redirect ends outside the allowlist. A transport that cannot report the final URL fails closed and logs once.
  • iOS sends User-Agent: NativeScript-HTTP-ESM (Android already did).
  • Android: Clear-Site-Data clears the response origin and the fetching origin (iOS's rule), instead of only the response origin or everything.
  • iOS: failed cache clears are reported (CacheOpResult), as Android's were.

Commits

  1. feat(http): lift the HTTP module loader's policy into the core: classification, the allowlist, canonicalization and host classes, moved with identical behavior and failure texts. Link-time platform functions in ns/Platform.h.
  2. feat(http): own the module fetch orchestration behind a transport seam: ns/http/ModuleTransport.h and ns/http/ModuleFetch.h. The core owns the gate, headers, timeouts, the single transport-error retry, deadline clamping, the sync fallback's wait bound, the cache switch with its holders, Clear-Site-Data, and capped fetch threads for transports that block. D1–D10 are recorded as decided in DESIGN.md §7 D.

Tests

Host tests against a fake platform and transport: the gate and the post-redirect check with isDebug=false (the device suites run Debug and never reach the gate), retries, deadlines, both scheduling modes, lane caps, the cache switch, and Clear-Site-Data. They pass under ASan/UBSan and TSan locally. Mutating the fail-closed check, the retry limit or the origin dedupe makes them fail.

Response classification (MIME rules, failure texts, the empty-module
rule), the remote-module allowlist, registry-key canonicalization and
fetch host classes, moved from both runtimes' HttpLoader with identical
behavior and failure texts. The core reaches the runtime through
link-time platform functions (ns/Platform.h): logging, trace categories,
and the runtime's URL normalization and origin.

Host tests link a fake platform.
The core now runs every HTTP module fetch and a platform transport only
performs single attempts (ns/http/ModuleTransport.h): the gate, the
request headers, timeouts, the single transport-error retry, deadline
clamping, the synchronous fallback's wait bound, classification, the
cache switch with its holders, and Clear-Site-Data. Transports that block
run on fetch threads capped per host class; transports that schedule
themselves get their retry delay from a core timer thread.

Decisions D1-D10 from the design (docs/DESIGN.md section 7 D), including
changes from today's runtimes:
- the gate is re-checked against the URL a redirect ended at;
- User-Agent: NativeScript-HTTP-ESM on every transport;
- Clear-Site-Data clears the response and the fetching origin;
- failed cache clears are reported through CacheOpResult.
@coderabbitai

coderabbitai Bot commented Dec 5, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Free
  • Run ID: 0eed386e-6eae-451b-bf4a-477d006622be

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

NativeScript is on CodeRabbit Free, which includes PR summaries. Ask your admin to upgrade for code reviews.

  • Ask an admin to upgrade

Open in CodeRabbit

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

1 participant