[PR #914] [CLOSED] fix(dev): show sane compile times when worker uses wall-clock performance.now() #944

Closed
opened 2026-05-06 13:11:00 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/914
Author: @james-elicx
Created: 4/26/2026
Status: Closed

Base: mainHead: claude/interesting-curie-b7ddb9


📝 Commits (4)

  • 609bedd fix(dev): show sane compile times when worker uses wall-clock performance.now()
  • 7fcebca fix(dev): use Date.now() for request timing to dodge workerd performance.now() origin
  • 72e5c96 fix(dev): drop NODE_ENV gate on __reqStart so it matches compileEnd capture
  • 3b866b2 fix(dev): derive compileMs from totalMs - renderMs to dodge workerd Spectre clock

📊 Changes

5 files changed (+49 additions, -53 deletions)

View changed files

📝 packages/vinext/src/entries/app-rsc-entry.ts (+8 -4)
📝 packages/vinext/src/index.ts (+19 -41)
📝 packages/vinext/src/server/app-page-render.ts (+3 -2)
📝 packages/vinext/src/server/app-page-response.ts (+15 -4)
📝 tests/app-page-response.test.ts (+4 -2)

📄 Description

Summary

  • The dev server was logging compile: 1777234570.6s (and similar absurd values) for App Router requests.
  • Cause: in workerd, performance.now() returns wall-clock time since epoch, but Node's performance.now() is process-uptime. The middleware subtracted the worker's handlerStart from the Node _reqStart to attribute Vite-transform overhead to "compile" — across two different time origins.
  • Fix: stop sending the absolute handlerStart timestamp across the worker→Node boundary. The X-Vinext-Timing header now carries only durations (compileMs,renderMs) computed inside the worker against a single clock. The Node middleware uses those values directly.

Tradeoff: we no longer attribute pre-handler Vite transform time to the "compile" metric. That overhead is mostly first-request module transforms and is already visible in Vite's own logs; the in-handler compile delta (dynamic module loading) is the dominant component and remains accurate.

Test plan

  • pnpm test:unit — all 3049 tests pass, including the updated app-page-response header-format assertions.
  • Manual: run vinext dev against an App Router app on Cloudflare and confirm compile: values are in the ms / sub-second range.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/914 **Author:** [@james-elicx](https://github.com/james-elicx) **Created:** 4/26/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `claude/interesting-curie-b7ddb9` --- ### 📝 Commits (4) - [`609bedd`](https://github.com/cloudflare/vinext/commit/609bedd566ffa3b49ae4a58b9410389488b1be94) fix(dev): show sane compile times when worker uses wall-clock performance.now() - [`7fcebca`](https://github.com/cloudflare/vinext/commit/7fcebcaf361d3c6a98db0e4fa9cc3bedf40bfc24) fix(dev): use Date.now() for request timing to dodge workerd performance.now() origin - [`72e5c96`](https://github.com/cloudflare/vinext/commit/72e5c9631f2af0647c3702e0031090fe5285cc95) fix(dev): drop NODE_ENV gate on __reqStart so it matches compileEnd capture - [`3b866b2`](https://github.com/cloudflare/vinext/commit/3b866b2bdee81d47073c03ac6d86c0407b76f585) fix(dev): derive compileMs from totalMs - renderMs to dodge workerd Spectre clock ### 📊 Changes **5 files changed** (+49 additions, -53 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/entries/app-rsc-entry.ts` (+8 -4) 📝 `packages/vinext/src/index.ts` (+19 -41) 📝 `packages/vinext/src/server/app-page-render.ts` (+3 -2) 📝 `packages/vinext/src/server/app-page-response.ts` (+15 -4) 📝 `tests/app-page-response.test.ts` (+4 -2) </details> ### 📄 Description ## Summary - The dev server was logging `compile: 1777234570.6s` (and similar absurd values) for App Router requests. - Cause: in workerd, `performance.now()` returns wall-clock time since epoch, but Node's `performance.now()` is process-uptime. The middleware subtracted the worker's `handlerStart` from the Node `_reqStart` to attribute Vite-transform overhead to "compile" — across two different time origins. - Fix: stop sending the absolute `handlerStart` timestamp across the worker→Node boundary. The `X-Vinext-Timing` header now carries only durations (`compileMs,renderMs`) computed inside the worker against a single clock. The Node middleware uses those values directly. Tradeoff: we no longer attribute pre-handler Vite transform time to the "compile" metric. That overhead is mostly first-request module transforms and is already visible in Vite's own logs; the in-handler compile delta (dynamic module loading) is the dominant component and remains accurate. ## Test plan - [x] `pnpm test:unit` — all 3049 tests pass, including the updated `app-page-response` header-format assertions. - [ ] Manual: run `vinext dev` against an App Router app on Cloudflare and confirm `compile:` values are in the ms / sub-second range. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:11:00 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#944
No description provided.