Skip to content

fix: allow cold remote modules to finish fetching - #3553

Merged
kwakayama merged 43 commits into
mainfrom
fix/esm-cold-fetch-timeout
Aug 10, 2026
Merged

kwakayama merged 43 commits into
mainfrom
fix/esm-cold-fetch-timeout

Conversation

@kojiwakayama

@kojiwakayama kojiwakayama commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • increase the per-attempt HTTP module fetch timeout from 2.5 seconds to 10 seconds
  • keep the complete three-attempt retry and backoff budget in one shared 30.3-second constant
  • set the module-loading idle deadline to 40 seconds so retry and in-flight wait budgets fit
  • propagate module-loading cancellation through transforms, in-flight waits, HTTP retries, and framework-module caching
  • cancel shared transform, framework-transform, and HTTP-fetch work only after the last render waiter detaches
  • broadcast shared framework progress to every active render
  • report progress after each successful remote-module fetch, including recursive dependency fetches
  • add focused cold-fetch, cancellation, retry-budget, shared-work, and recursive-progress regressions

Why

Cold upstream module generation can exceed the old 2.5-second deadline. The coordinated attempt, retry, in-flight wait, and module-loading budgets let valid cold responses finish without leaving canceled renders doing network or cache work. Concurrent renders can share transforms, framework transforms, and HTTP fetches safely, and useful recursive fetch progress refreshes each active render idle deadline.

Validation

  • red: the 6-second cold-fetch regression failed with the old attempt deadline
  • red: the full retry-budget invariant failed before the retry constants and outer deadline were coordinated
  • red: cancellation previously allowed all HTTP retry attempts to continue
  • red: canceling the leader previously canceled shared HTTP and framework work needed by active followers
  • red: recursive dependency fetches previously emitted no idle-deadline progress
  • green: transform, ESM, pipeline, and module-loader suites, 70 tests and 1,118 steps
  • green: generated-manifest checks and full typecheck
  • green: API reference check, formatting, and lint
  • green: npm package and extension build
  • exact-head CI and merge-queue checks are required before merge

Related: https://github.com/veryfront/veryfront-issue-inbox/issues/456

Summary by CodeRabbit

  • Improvements
    • Increased module-loading timeout to 40 seconds for slower or cold generation.
    • Extended HTTP fetch timeouts and added controlled retries for more reliable loading.
    • Improved cancellation across network, caching, and transformation work while preserving abort reasons.
    • Shared in-progress work now avoids duplicate fetches and continues for remaining callers.
    • Improved progress reporting for shared and recursive module transformations.
    • Standardized development-server command handling across Deno, npm, and Bun.
  • Documentation
    • Updated HTTP configuration references and clarified timeout behavior.

A cold esm.sh module can take longer than the previous per-attempt deadline, causing three aborted requests even though the upstream response would succeed. Extend one attempt to cover cold generation and lock the boundary with an abort-aware fetch regression.

Constraint: Cold esm.sh package generation can exceed 2.5 seconds.

Rejected: Add more retries | Repeating the same short deadline never lets a slow successful response finish.

Confidence: high

Scope-risk: narrow

Reversibility: clean

Directive: Keep the attempt timeout above realistic cold upstream generation latency.

Tested: Red-green HTTP cache regression, 699-step ESM transform suite, format, lint, typecheck, isolated Deno ai-agent journey, and all 21 scaffold/build/serve/browser template-runtime cases.

Not-tested: None.
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

HTTP module fetching now uses shared retry budgets, cancellation, progress reporting, and in-flight waiter management. Abort signals propagate through transforms and SSR module processing. Module-loading timeouts increase to 40 seconds. Runtime command construction is centralized and tested for Deno, npm, and Bun.

Changes

HTTP module fetch lifecycle

Layer / File(s) Summary
Timeout and retry configuration
src/utils/constants/http.ts, src/transforms/esm/http-cache.ts, src/rendering/orchestrator/module-collection.ts, src/rendering/orchestrator/module-collection.test.ts, src/rendering/orchestrator/pipeline.behavior.test.ts, docs/api-reference/veryfront/utils.md
Shared constants define HTTP retry limits and budgets. The HTTP fetch timeout is 10 seconds, and the module-loading timeout is 40 seconds.
Abort signal contracts and propagation
src/transforms/pipeline/types.ts, src/transforms/pipeline/context.ts, src/transforms/pipeline/context.test.ts, src/transforms/esm/types.ts, src/transforms/esm/http-cache-helpers.ts, src/transforms/pipeline/stages/ssr-http-cache.ts, src/rendering/orchestrator/module-loader/module-transform-cache.ts, src/rendering/orchestrator/module-loader/module-transform-cache.test.ts, src/transforms/pipeline/stages/ssr-vf-modules/constants.ts, src/transforms/pipeline/stages/ssr-vf-modules/transform.ts
Transform options and contexts carry abort signals and progress callbacks into HTTP caching, transformToESM, and framework transformations.
Shared HTTP fetch lifecycle
src/transforms/esm/in-flight-manager.ts, src/transforms/esm/http-cache.ts, src/transforms/esm/http-cache-state.ts
Shared fetches deduplicate work, track waiters, forward progress, honor caller cancellation, and abort unfinished work when no waiters remain.
Shared transform flights
src/transforms/esm/transform-cache.ts, src/transforms/esm/transform-cache.test.ts, src/transforms/pipeline/stages/ssr-vf-modules/index.ts, src/transforms/pipeline/stages/ssr-vf-modules.test.ts
Transform and framework flights share execution and progress events. Caller cancellation detaches one waiter, while final-waiter removal aborts unfinished work.
Fetch and cancellation regression coverage
src/transforms/esm/http-cache.test.ts, src/transforms/esm/in-flight-manager.test.ts, src/transforms/esm/transform-cache.test.ts, src/transforms/pipeline/stages/ssr-vf-modules.test.ts
Tests cover delayed cold fetches, retry-window limits, cancellation reasons, shared waiters, recursive progress, circular requests, and cleanup after cancellation.

Template runtime command construction

Layer / File(s) Summary
Runtime command helper
scripts/test/template-runtime-e2e.ts, scripts/test/template-runtime-e2e.test.ts, deno.json
getDevServerCommand centralizes Deno, npm, and Bun command construction. The script task runs the new end-to-end tests.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Suggested reviewers: kwakayama

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.10% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: allowing cold remote modules to complete fetching.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/esm-cold-fetch-timeout

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 28e3fc04e9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/utils/constants/http.ts
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f260c7d11c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/utils/constants/http.ts
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 72d7936a82

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/transforms/esm/http-cache.test.ts Outdated
The retry-budget regression imports a runtime orchestrator constant from outside its directory. Use the repository import map path so the test follows the same internal import convention as nearby Veryfront modules.

Constraint: Review requested the #veryfront rendering orchestrator import path.

Rejected: Keep the relative import | inconsistent with internal source import conventions and the PR review request.

Confidence: high

Scope-risk: narrow

Directive: Prefer #veryfront/* imports for cross-subtree internal source references in tests.

Tested: deno test --preload=src/testing/preload.ts --no-check --allow-all src/transforms/esm/http-cache.test.ts

Tested: deno test --preload=src/testing/preload.ts --no-check --allow-all src/transforms/esm

Tested: deno task fmt:check

Tested: deno task lint

Not-tested: Full unit suite; change is limited to a test import path.
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: b4d4f52335

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@kojiwakayama
kojiwakayama added this pull request to the merge queue Aug 10, 2026
Cold esm.sh module generation can exceed five seconds, as the full Bun template journey reproduced. Restore the ten-second fetch attempt and expand the module-loading idle window so a stalled attempt can retry before the unchanged hard cap.

Constraint: Cold upstream module generation exceeded five seconds in a real Bun production build.
Constraint: Module loading must allow a retry while retaining the 45 second hard cap.
Rejected: Keep the five second fetch timeout | fails cold ai-agent builds.
Rejected: Restore ten seconds without changing module idle timeout | render deadline wins before retry.
Confidence: high
Scope-risk: moderate
Reversibility: clean
Directive: Keep two HTTP module attempts plus retry delay within MODULE_LOAD_TIMEOUT_MS.
Tested: Six-second cold response regression; transform and rendering suites (64 tests, 1086 steps); all seven templates on Node, Bun, and Deno (21 journeys).
Not-tested: Native network outages exceeding the 45 second hard cap.
@kojiwakayama
kojiwakayama removed this pull request from the merge queue due to a manual request Aug 10, 2026
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/transforms/esm/http-cache.test.ts (1)

101-104: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Include retry backoff in the timeout invariant.

fetchHttpModule applies HTTP_MODULE_FETCH_TIMEOUT_MS per attempt and adds HTTP_MODULE_FETCH_RETRY_DELAY_MS before the next attempt in src/transforms/esm/http-cache.ts:191-254. This assertion checks only the per-attempt timeout. It can pass while retry backoff consumes the remaining module-loading idle window. Include the retry delay in the first-retry deadline assertion.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/transforms/esm/http-cache.test.ts` around lines 101 - 104, Update the
timeout invariant test around “keeps a retry attempt within the module-loading
idle deadline” to include HTTP_MODULE_FETCH_RETRY_DELAY_MS alongside
HTTP_MODULE_FETCH_TIMEOUT_MS when comparing against MODULE_LOAD_TIMEOUT_MS / 2.
Preserve the existing first-retry deadline constraint while accounting for both
the attempt duration and backoff.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/transforms/esm/http-cache.test.ts`:
- Around line 101-104: Update the timeout invariant test around “keeps a retry
attempt within the module-loading idle deadline” to include
HTTP_MODULE_FETCH_RETRY_DELAY_MS alongside HTTP_MODULE_FETCH_TIMEOUT_MS when
comparing against MODULE_LOAD_TIMEOUT_MS / 2. Preserve the existing first-retry
deadline constraint while accounting for both the attempt duration and backoff.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3ce81730-bb29-4781-ae6d-c86e55607859

📥 Commits

Reviewing files that changed from the base of the PR and between 28e3fc0 and cf44da3.

📒 Files selected for processing (4)
  • docs/api-reference/veryfront/utils.md
  • src/rendering/orchestrator/module-collection.test.ts
  • src/rendering/orchestrator/module-collection.ts
  • src/transforms/esm/http-cache.test.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf44da3b1c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/rendering/orchestrator/module-collection.ts Outdated
@kwakayama
kwakayama enabled auto-merge August 10, 2026 19:25
@kwakayama
kwakayama disabled auto-merge August 10, 2026 19:26
@kwakayama
kwakayama enabled auto-merge August 10, 2026 19:26
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

Addressed the CodeRabbit retry-backoff nitpick in fbfc017 as part of the shared full-sequence retry budget. The invariant now includes every attempt and backoff.

@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

@kojiwakayama

Copy link
Copy Markdown
Contributor Author

The exact-head typecheck exposed a stale generated client template. Refreshed it in bc34d85; the complete deno task typecheck now passes locally.

@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 10f5df7b1a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/transforms/esm/http-cache.ts Outdated
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 06d17a9589

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/rendering/orchestrator/module-collection.ts
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: c18ce40b15

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

The template runtime harness installs a packed Veryfront CLI below the generated project so Deno can exercise the release artifact. Treat that hidden dependency root like node_modules during style discovery, preventing its thousands of framework files from exhausting the candidate budget.

Constraint: Deno template E2E must run against the packed release artifact.

Rejected: Raise the CSS candidate limit | it would mask dependency scanning and increase resource exposure.

Confidence: high

Scope-risk: narrow

Directive: Keep .veryfront-packed-cli outside application style discovery unless it becomes a supported source root.

Tested: style-scope-profile unit test; packed Deno multi-agent scaffold, install, serve, HTTP, and browser journey

Not-tested: Full 21-case template matrix pending after push
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 492cce0d98

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8f51e2dd36

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/transforms/esm/http-cache.ts Outdated
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 6d113ceb2e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

2 participants