Skip to content

fix: stop permanent 504 Outdated Optimize Dep under multi-environment plugins - #260

Merged
rturnq merged 1 commit into
mainfrom
ryanturnquist-Mac-run-agent-triage-p2d582-cf-outdated-dep
Aug 12, 2026
Merged

rturnq merged 1 commit into
mainfrom
ryanturnquist-Mac-run-agent-triage-p2d582-cf-outdated-dep

Conversation

@rturnq

@rturnq rturnq commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Description

@marko/run: dev client environments now set optimizeDeps.ignoreOutdatedRequests (respecting an explicit user value), so a dep whose embedded hash diverged from the optimizer's committed hash serves the current bundle instead of 504ing forever.

Motivation and Context

With a multi-environment plugin sharing the dev server (reproduced with @cloudflare/vite-plugin and viteEnvironment: { name: "ssr" }), every request for an optimized client dep like marko/debug/dom returned 504 Outdated Optimize Dep and the reload loop never converged — zero hydration in dev. Bisected to Vite 8.1.4 (vitejs/vite#22852): a client dep discovered before the optimizer finishes init keeps its discovery-time hash after later commits, so the rewrite embeds a hash serving permanently rejects. Verified against the repro on Vite 8.1.5: the previously-504ing URL serves 200 with this change. The underlying stale-entry behavior is a Vite bug to report upstream.

Checklist:

  • I have updated/added documentation affected by my changes.
  • I have added tests to cover my changes.

@changeset-bot

changeset-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: eb5f176

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@marko/run Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

configEnvironment now excludes @marko/run/router from dependency optimization. Non-build environments return this configuration early. Client environments default ignoreOutdatedRequests to true. Build environments retain custom resolve conditions. The pull request adds a patch changeset for @marko/run and removes the documented bug report for the Vite 504 loop.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix for persistent 504 Outdated Optimize Dep responses under multi-environment plugins.
Description check ✅ Passed The description directly explains the affected behavior, root cause, motivation, and implemented fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ryanturnquist-Mac-run-agent-triage-p2d582-cf-outdated-dep

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

@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)
packages/run/src/vite/plugin.ts (1)

561-563: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Shorten the new comment.

The comment spans three lines and records a version-specific regression. Replace it with a one- or two-line intent statement.

As per coding guidelines, comments must be a last resort, limited to two lines, and capture intent rather than historical implementation details.

Proposed change
-          // Since vite 8.1.4 a client dep discovered before the optimizer
-          // finishes init keeps a permanently stale hash under multi-environment
-          // plugins (e.g. `@cloudflare/vite-plugin`), 504ing every request for it.
+          // Avoid stale optimized-dependency responses in multi-environment dev.
🤖 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 `@packages/run/src/vite/plugin.ts` around lines 561 - 563, Shorten the comment
above the optimizer initialization logic to one or two lines that state the
intent: defer handling client dependencies until optimizer initialization
completes to avoid stale hashes in multi-environment plugins. Remove the Vite
version reference, regression history, and request-level symptom details.

Source: Coding guidelines

🤖 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 `@packages/run/src/vite/plugin.ts`:
- Around line 561-563: Shorten the comment above the optimizer initialization
logic to one or two lines that state the intent: defer handling client
dependencies until optimizer initialization completes to avoid stale hashes in
multi-environment plugins. Remove the Vite version reference, regression
history, and request-level symptom details.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c1c38d1c-8afc-4f58-9a6f-ab08aa3197a9

📥 Commits

Reviewing files that changed from the base of the PR and between f0ad866 and eb5f176.

📒 Files selected for processing (3)
  • .changeset/cf-outdated-optimize-dep.md
  • agent-feedback/bugs.md
  • packages/run/src/vite/plugin.ts
💤 Files with no reviewable changes (1)
  • agent-feedback/bugs.md

@rturnq
rturnq merged commit b39dfce into main Aug 12, 2026
8 checks passed
@rturnq
rturnq deleted the ryanturnquist-Mac-run-agent-triage-p2d582-cf-outdated-dep branch August 12, 2026 04:17
@github-project-automation github-project-automation Bot moved this to Todo in Roadmap Sep 1, 2026
@github-project-automation github-project-automation Bot moved this from Todo to Done in Roadmap Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant