types: clarify DispatchNamespace.get does not throw on missing worker (fixes #5263)#6765
Open
LeSingh1 wants to merge 1 commit into
Open
types: clarify DispatchNamespace.get does not throw on missing worker (fixes #5263)#6765LeSingh1 wants to merge 1 commit into
LeSingh1 wants to merge 1 commit into
Conversation
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>
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The JSDoc for
DispatchNamespace.getintypes/defines/wfp.d.tsclaimed:In practice,
getalways returns aFetcher; the "Worker not found" error is only surfaced when the returned Fetcher'sfetch()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 thefetch()try/catch), which confirms the runtime behavior is intentional — only the JSDoc was misleading.Fix
Replaced the inaccurate
@throwsline 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).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 viabazel 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.Issue
Fixes #5263