Skip to content

Keep the task host out of the edge bundle - #72

Merged
hannahhoward merged 1 commit into
mainfrom
fix/edge-instrumentation
Sep 21, 2026
Merged

hannahhoward merged 1 commit into
mainfrom
fix/edge-instrumentation

Conversation

@hannahhoward

@hannahhoward hannahhoward commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • apps/web/instrumentation.ts declines the edge runtime by name and loads the task host through a dynamic import, so src/task-host.ts never enters the edge bundle.

Next builds instrumentation.ts for every runtime it has, and this app has an edge one because proxy.ts is middleware. The edge build followed the top-level import into src/task-host.ts, found process.exit and process.once, and failed to compile. Turbopack retried it on the next request and the one after: about seventy failed compiles per page in next dev, each printing its stack, none of them for code the edge runtime was ever going to call.

On the macos CI runner that cost lands on whichever expectation is waiting for a route to finish compiling. That is how run 35555556886 went red: ux-shell.spec.ts waited 95 seconds for /quotes, spent its whole 120-second budget, and took the command-palette test and 25 unrun tests with it. The same shard was green on the commit before at 60 seconds for that test, so this had been marginal since #60 landed rather than broken outright. The red run's own change was Terraform only.

Excluding edge rather than requiring node is deliberate, and src/task-host.ts records why at its own guard: the standalone server can reach a runtime check with NEXT_RUNTIME unset, and a host that starts nowhere neither drains the queue nor handles SIGTERM. Unset starts the host; only the literal "edge" declines.

Deliverables

File Status Summary
apps/web/instrumentation.ts Modified Skip the edge runtime, load the host dynamically

Test plan

  • Cleared dev cache, three page loads: 268 failed edge compiles before, 0 after
  • next build then pnpm start with CLOCKWORK_TASK_RUNTIME=sqs still reaches the poller, failing only on this machine's missing CLOCKWORK_SERVICE_DATABASE_URL
  • ux-shell.spec.ts 15/15 locally, including both tests that failed on CI
  • src/task-host.test.ts 8/8
  • The ui shard goes green on CI: 113/113, with the drawer test at 31.1s against 122.9s on the red run and 60.3s on the last green one

🤖 Generated with Claude Code

https://claude.ai/code/session_01RzTEVpxi5LHTXSZywnFjea

Next builds `instrumentation.ts` for every runtime it has, and this app has
an edge one because `proxy.ts` is middleware. The edge build followed the
top-level import into `src/task-host.ts`, found `process.exit` and
`process.once`, and failed to compile. Turbopack retried it on the next
request and the one after that: about seventy failed compiles per page in
`next dev`, each printing its stack, none of them for code the edge runtime
was ever going to call.

On the macos CI runner that cost is charged to whichever expectation is
waiting for a route to finish compiling. It is how `ux-shell.spec.ts` spent
95 seconds waiting for `/quotes` on the run that went red, and then its whole
120-second budget, taking the command-palette test and 25 unrun tests with
it. The same shard was green on the commit before at 60 seconds for that
test, so this had been marginal since the runtime landed rather than broken
outright.

The hook now declines the edge runtime by name and loads the host through a
dynamic import, because a top-level import puts the module in the edge bundle
whatever the guard decides at runtime. Excluding edge rather than requiring
node is deliberate, and `src/task-host.ts` records why at its own guard: the
standalone server can reach a runtime check with `NEXT_RUNTIME` unset, and a
host that starts nowhere neither drains the queue nor handles SIGTERM.

Measured on a cleared dev cache, three page loads: 268 failed edge compiles
before, 0 after. A production build with `CLOCKWORK_TASK_RUNTIME=sqs` still
reaches the poller, failing only on this machine's missing database URL.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RzTEVpxi5LHTXSZywnFjea
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-21T03:22:41.362935Z e77d56e PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@hannahhoward
hannahhoward merged commit ba7ac8b into main Sep 21, 2026
16 of 18 checks passed
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