Skip to content

types: clarify DispatchNamespace.get does not throw on missing worker (fixes #5263)#6765

Open
LeSingh1 wants to merge 1 commit into
cloudflare:mainfrom
LeSingh1:docs-dispatch-namespace-throws-on-fetch
Open

types: clarify DispatchNamespace.get does not throw on missing worker (fixes #5263)#6765
LeSingh1 wants to merge 1 commit into
cloudflare:mainfrom
LeSingh1:docs-dispatch-namespace-throws-on-fetch

Conversation

@LeSingh1
Copy link
Copy Markdown

Summary

The JSDoc for DispatchNamespace.get in types/defines/wfp.d.ts claimed:

@throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.

In practice, get always returns a Fetcher; the "Worker not found" error is only surfaced when the returned Fetcher's fetch() is invoked. The reporter demonstrated this with a clear repro in #5263. The dynamic dispatch example in the Cloudflare docs already documents the workaround (e.message.startsWith('Worker not found') inside the fetch() try/catch), which confirms the runtime behavior is intentional — only the JSDoc was misleading.

Fix

Replaced the inaccurate @throws line with a note describing the actual behavior and where the error surfaces. This is a docs-only change; no runtime behavior is affected.

Updated:

  • types/defines/wfp.d.ts — the source definition (the file the issue links to is generated from this).
  • The four corresponding generated snapshots under types/generated-snapshot/{latest,experimental}/index.{ts,d.ts} so the snapshot check stays green. (I do not have a Bazel build environment to regenerate them via bazel build //types:types; if reviewers prefer the snapshots be regenerated, please tell me and I'll redo locally.)

Verification

  • grep -rn "@throws If the Worker script does not exist" types/ returns no remaining matches after the patch.
  • Patch is comments-only — no source/runtime change.

Issue

Fixes #5263

The JSDoc for `DispatchNamespace.get` claimed an error would be thrown
when the named Worker script does not exist in the dispatch namespace.
In practice, `get` always returns a `Fetcher`; the "Worker not found"
error is only surfaced when the returned Fetcher's `fetch()` is invoked.
A user-facing example on developers.cloudflare.com already documents the
workaround (`e.message.startsWith('Worker not found')` inside the fetch
try/catch), so the runtime behavior is intentional -- only the JSDoc
was misleading.

Replace the inaccurate `@throws` line with a note describing the actual
behavior and where the error surfaces. Updates `types/defines/wfp.d.ts`
plus the corresponding latest/experimental generated snapshots so the
docs stay in sync.

Fixes cloudflare#5263

Signed-off-by: LeSingh1 <sshaurya914@gmail.com>
@LeSingh1 LeSingh1 requested review from a team as code owners May 18, 2026 02:04
@LeSingh1 LeSingh1 requested a review from ascorbic May 18, 2026 02:05
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 18, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@LeSingh1
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request May 18, 2026
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.

DispatchNamespace.get does not throw on missing worker as documented

1 participant