Remove note about a fetch handler being required alongside DOs - #5185
Merged
Conversation
Because we're removing that requirement on script upload. It's still often a good idea to bundle a fetch handler with a DO class, but will no longer be required.
koeninger
approved these changes
Jul 18, 2022
Member
Author
|
I've confirmed this behavior is live. |
taylorlee
added a commit
to cloudflare/workers-sdk
that referenced
this pull request
Sep 5, 2026
Fixes #15309. The legacy heuristic of assuming anything without a default export is going more harm than good. It also seems like it must have regressed at some point, because it used to be possible to have DO-class-only Workers a [few years ago](cloudflare/cloudflare-docs#5185), even though trying that now would fail by detecting SW syntax. After looking at a bunch of options and various forms of required back-compat, I think the best path forward is to resolve the ambigious case in favor of modules workers. Current heuristic: * default export -> module worker * otherwise -> service worker New heuristic: * no exports -> service worker * default export -> module worker * ambigious exports: - recognized global addEventListener reference -> service worker - otherwise -> module worker This does that the most tricky dynamic constructions of SW can be falsely interpreted as module workers if they have some named exports. I think that's acceptable for a 2 reasons: 1. it is less harmful than misclassifying MW as SW 2. many of the most dynamic constructions (of either MW or SW) can't actually be deployed in practice (due to preexisting validator limitations), so the real breakage is minimal. Alternatives considered: export-only heuristics, source regexes, entrypoint-specific AST matching, an additional parser, and full dependency bundling. These were avoided due to compatibility risks, false positives, added complexity, or resolution overhead.
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.
Because we're removing that requirement on script upload. It's still
often a good idea to bundle a fetch handler with a DO class, but will no
longer be required.