Remove loopback for Asset worker#14417
Conversation
🦋 Changeset detectedLatest commit: 7dc3f67 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
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 |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
|
✅ All changesets look good |
|
The miniflare asset service uses the default export of I've completed a thorough review. The change is functionally sound:
One minor note worth raising: the new test uses No logic bugs, security issues, backward-compatibility violations, or incorrect API behavior found. LGTM |
@cloudflare/autoconfig
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
There was a problem hiding this comment.
🚩 Trace context behavior change when AssetWorkerInner is called directly
When AssetWorkerInner is called directly as the default export (not via loopback), loopbackCtx.props?.traceContext at packages/workers-shared/asset-worker/src/worker.ts:523 evaluates to null. This null value is then passed to this.env.JAEGER.runWithSpanContext(null, ...) at line 526. Previously, AssetWorkerOuter would capture the active span context via this.env.JAEGER.getSpanContext() and forward it to the inner entrypoint through ctx.props. Now the inner entrypoint passes null when called directly, relying on the JAEGER binding to either preserve the existing runtime-established context or handle null as a no-op. This is likely fine because the runtime should already have the correct trace context active when calling the default entrypoint directly, but it's worth confirming that runWithSpanContext(null, ...) doesn't inadvertently clear an active trace context in production.
(Refers to lines 522-537)
Was this helpful? React with 👍 or 👎 to provide feedback.
| Bypass the Asset Worker loopback on normal request and RPC paths | ||
|
|
||
| The inner asset entrypoint is now the default, avoiding the latency added by forwarding every call through `ctx.exports`. The outer loopback entrypoint and its cohort-routing infrastructure remain available as named exports in the Asset Worker and Miniflare bundles so the boundary can be re-enabled later. |
There was a problem hiding this comment.
🟡 Changeset description contains implementation details instead of user-facing impact
The REVIEW.md rule states: "Changesets should target users of the tools (e.g. Wrangler users) rather than maintainers. Avoid including implementation details like 'moves X from hybridModules to nativeModules'." The changeset body mentions internal implementation concepts: "inner asset entrypoint", "ctx.exports", "outer loopback entrypoint", "cohort-routing infrastructure", and "named exports in the Asset Worker and Miniflare bundles." A user-facing description should focus on the performance benefit (e.g., "Improve asset serving latency by removing an unnecessary internal request hop").
| Bypass the Asset Worker loopback on normal request and RPC paths | |
| The inner asset entrypoint is now the default, avoiding the latency added by forwarding every call through `ctx.exports`. The outer loopback entrypoint and its cohort-routing infrastructure remain available as named exports in the Asset Worker and Miniflare bundles so the boundary can be re-enabled later. | |
| Improve asset serving performance by removing an unnecessary internal dispatch hop | |
| Asset requests and RPC calls now avoid an extra round-trip through an internal forwarding layer, reducing latency. The forwarding infrastructure is preserved for future use by cohort-based deployments. | |
Was this helpful? React with 👍 or 👎 to provide feedback.
jamesopstad
left a comment
There was a problem hiding this comment.
Looks good. The Devin comments will need resolving before merging.
af4b7ea to
7dc3f67
Compare
Fixes WC-5345.
Bypass the Asset Worker loopback on normal request and RPC paths
The inner asset entrypoint is now the default, avoiding the latency added by forwarding every call through
ctx.exports. The outer loopback entrypoint and its cohort-routing infrastructure remain available as named exports in the Asset Worker and Miniflare bundles so the boundary can be re-enabled later.A picture of a cute animal (not mandatory, but encouraged)