Skip to content

Fetch script metadata directly instead of listing all scripts - #15132

Merged
dario-piotrowicz merged 2 commits into
mainfrom
dario/fetch-directly-for-script-metadata
Aug 11, 2026
Merged

Fetch script metadata directly instead of listing all scripts#15132
dario-piotrowicz merged 2 commits into
mainfrom
dario/fetch-directly-for-script-metadata

Conversation

@dario-piotrowicz

Copy link
Copy Markdown
Member

When resolving Durable Object migrations, fetch the specific script's service metadata via /workers/services/{name} instead of listing all scripts in the account via /workers/scripts. This avoids downloading metadata for every Worker in the account just to find one script's migration tag.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: performance fix

A picture of a cute animal (not mandatory, but encouraged)

@changeset-bot

changeset-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: dc757b4

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

This PR includes changesets to release 5 packages
Name Type
@cloudflare/deploy-helpers Patch
wrangler Patch
@cloudflare/remote-bindings Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers 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

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

All changesets look good

@ask-bonk

ask-bonk Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

So mockSubDomainRequest("test-sub-domain", true, false) just sets once=false (allowing the subdomain handler to respond multiple times). This is a test-mock adjustment in the "no previous script" test cases, likely because the deploy flow now retries/re-requests. This is a test-only concern and not a logic bug.

My analysis is complete. The change is well-implemented:

  1. Consolidates to a single endpoint — the CI-tag flow (match-tag.ts) already fetches /workers/services/{name} in the same deploy, so this reuses an established path and reduces payload.
  2. Error handling is consistentisWorkerNotFoundError + codes 10090/10007 match the established pattern used in match-tag.ts and other tests.
  3. Type usage is correctServiceMetadataRes.default_environment.script is always present per the type.
  4. Mock changes are appropriate — dropping { once: true } correctly allows the shared endpoint to answer both the pre-upload check and the migration flow.

I found no logic bugs, security issues, backward-compatibility violations, or incorrect API behavior. The behavior for the "script not found" case (apply all migrations) is preserved: previously .find() returned undefined; now the not-found error is suppressed leaving script undefined — same downstream result.

LGTM

github run

@pkg-pr-new

pkg-pr-new Bot commented Aug 11, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@15132

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@15132

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@15132

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@15132

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@15132

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@15132

miniflare

npm i https://pkg.pr.new/miniflare@15132

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@15132

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@15132

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@15132

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@15132

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@15132

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@15132

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@15132

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@15132

wrangler

npm i https://pkg.pr.new/wrangler@15132

commit: dc757b4

@dario-piotrowicz
dario-piotrowicz marked this pull request as ready for review August 11, 2026 15:31
@workers-devprod
workers-devprod requested review from a team and petebacondarwin and removed request for a team August 11, 2026 15:31
@workers-devprod

workers-devprod commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/cloudchamber
  • ✅ @cloudflare/wrangler
Show detailed file reviewers
  • packages/wrangler/src/tests/containers/deploy.test.ts: [@cloudflare/cloudchamber]

devin-ai-integration[bot]

This comment was marked as resolved.

Comment thread .changeset/fetch-script-metadata-directly.md
Comment thread packages/deploy-helpers/src/deploy/helpers/durable.ts
devin-ai-integration[bot]

This comment was marked as resolved.

@dario-piotrowicz
dario-piotrowicz force-pushed the dario/fetch-directly-for-script-metadata branch from aca2d32 to dc757b4 Compare August 11, 2026 18:01
@dario-piotrowicz
dario-piotrowicz merged commit 5b1b930 into main Aug 11, 2026
63 of 65 checks passed
@dario-piotrowicz
dario-piotrowicz deleted the dario/fetch-directly-for-script-metadata branch August 11, 2026 18:32
@github-project-automation github-project-automation Bot moved this from Untriaged to Done in workers-sdk Aug 11, 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.

3 participants