You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 41caa01
Browse filesBrowse the repository at this point in the historyBrowse files
fix(runtime): bound HTTP module fetches by the graph walk's deadline (#2171)
### Description
A pumped graph walk waits at most `kModuleEvaluateDeadlineSeconds` for
its fetches. Each async attempt, though, carried a flat 15 s connect +
15 s read timeout and retried once unconditionally. A stalled edge could
therefore keep fetching long after the wait had given up on it.
- **One timeout policy.** `ModuleFetchTimeoutMs()` sets the connect and
read timeouts of every attempt: **30 s in debug builds and 5 s in
release builds**, the values iOS uses. That replaces 15 s / 15 s in
both. Dev servers transform cold modules on demand. NativeScript/ios#552
reports toolchain responses of 5–9 s, which is why debug gets the longer
budget.
- **The deadline reaches every fetch.** The pumped walk takes its
deadline before it starts and hands it to every fetch it issues
(`AsyncGraphLoad::fetchDeadline`). Each async attempt:
- clamps both timeouts to the time remaining;
- retries only while the budget still fits the 120 ms retry delay;
- fails with `HTTP import failed: <url> (module graph fetch deadline
exceeded)` without issuing a request when it would start past the
deadline, including when it was queued behind the concurrency cap.
- A dynamic `import()` of an HTTP root passes no deadline and stays
unbounded, since nothing waits on it. The synchronous fallback keeps its
single retry.
The docs now give the timeout values and the deadline rules in place of
the old per-attempt-bounds caveat.
#### Notes for review
- **Release builds tighten from 15 s to 5 s per connect and per read.**
This only affects release apps that set `security.allowRemoteModules`. A
slow remote origin that answered within 15 s now fails at 5 s, as it
does on iOS.
- **The timeouts are still per-connect and per-read inactivity bounds,
not totals.** A response that keeps dripping in can run past the
deadline. The pumped wait gives up on it at the deadline regardless.
- Transport timeouts were one of the cross-platform items listed in
#2020. They now match iOS.
### Does your commit message include the wording below to reference a
specific issue in this repo?
No. It relates to #2020, a tracking issue that should stay open.
### Related Pull Requests
Mirrors NativeScript/ios#552, including its timeout values and its
slow-transform specs. The `/esm/slow/` and `/esm/request-stats.json`
test-server routes it relies on came in earlier in this stack.
Part of a stack of six; each PR targets the branch below it:
1. #2168 `fix/http-importer-specifiers`: specifier resolution from HTTP
importers
2. #2169 `refactor/module-url-parse`: one URL parse for every http(s)
entry point
3. #2170 `perf/http-module-streaming-compile`: compile large HTTP
modules off the JS thread
4. #2171 `fix/http-module-fetch-budget`: bound fetches by the graph
walk's deadline (**this PR**)
5. #2172 `perf/http-module-transport`: persistent connections,
per-host-class caps, OkHttp transport
6. #2173 `feat/http-module-cache-controls`: HTTP module cache controls
### Does your pull request have [unit
tests](https://github.com/NativeScript/NativeScript/blob/master/running-tests.md)?
Yes. A new "fetch budget" group in `testEsmHttpLoader.js` uses
`/esm/request-stats.json` to prove that each module was requested
exactly once, with no retry and no synchronous-fallback round trip:
- a 7 s module resolves on its first request;
- a 7 s re-export chain resolves on one request per module;
- a pumped `require()` through a local→HTTP boundary waits for a 7 s
leaf.
Full suite on the top of the stack (`./gradlew
runtestsAndVerifyResults`): 2074 specs, 2068 passed, 0 failed, 6 skipped
(the usual GC, native-module and environment skips), on an API 36 arm64
emulator with OkHttp in the test app, at
`feat/http-module-cache-controls` 21f87a8.
This stays a draft until the stack has been run against a real Vite dev
session on Android, which has not happened yet.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Bug Fixes**
* HTTP module graph loads now honor a shared time limit across fetching
and retries, helping slow or stalled imports fail predictably.
* Transport errors receive one brief retry when time remains; requests
that can no longer fit within the deadline are skipped.
* Dynamic imports and synchronous fallback fetches retain their existing
per-attempt timeout behavior.
* **Tests**
* Added coverage for delayed HTTP modules, re-export chains, and modules
loaded through `require()`.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
0 commit comments