align README outbound examples with egress docs - #248
Open
iMagdy wants to merge 1 commit into
Open
Conversation
The three static outbound accessors — outbound, outboundByHost and outboundHandlers — must be set by assignment after the class declaration. Written as `static` class fields they are installed with [[DefineOwnProperty]] under useDefineForClassFields (the default for target ES2022 and above), which shadows the inherited setter instead of invoking it. The handler is never registered and outbound requests fail closed with 520, with no error or warning. docs/egress.md already uses the assignment form in all six of its examples; README.md used the class-field form in all six of its own. This brings the README in line with the egress docs. Instance properties in the same example (allowedHosts, deniedHosts, interceptHttps, enableInternet, defaultPort) are plain properties rather than accessors, so they are correct as class fields and are unchanged. Refs cloudflare#247
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.
What
Align
README.mdwithdocs/egress.mdon how the three static outbound accessors are set:by assignment after the class declaration, not as
staticclass fields.Fixes the documentation half of #247.
Why
outbound,outboundByHostandoutboundHandlersare declared as static accessor pairs(
dist/lib/container.d.ts:50-55), and their setters are the only writers of the handlerregistry. Under
useDefineForClassFieldssemantics — the default fortarget: ES2022andabove — a
static outbound = …class field is installed with[[DefineOwnProperty]]. Thatcreates an own property which shadows the inherited setter instead of invoking it, so the
handler is never registered and every outbound request fails closed with
520 Origin is disallowed. No error, no warning, andMyContainer.outboundstill reads backthe function you assigned — it is just the own property, not a registration.
The repo already documents this correctly elsewhere.
docs/egress.mduses the assignmentform in all six of its examples (lines 150, 165, 177, 310, 316, 322):
while
README.mduses the class-field form in all six of its own (lines 311, 315, 319, 479,485, 491). This PR makes the README match the egress docs; it does not introduce a new
convention.
All three accessors are affected identically, not just
outbound.Changes
form does not register.
staticblocks out of the class body into assignmentsafter the declaration.
Instance properties in the same example (
allowedHosts,deniedHosts,interceptHttps,enableInternet,defaultPort) are plain properties rather than accessors, so they arecorrect as class fields and are left unchanged.
Docs-only — no changeset, no behaviour change.