Skip to content

Commit d67d80d

Browse files
committed
Preserve benchmark defaults for auth loaders
An authenticated document loader only affects authenticated key fetching. It should not disable benchmarkMode's private-address default for the regular document and context loaders, whose local benchmark behavior is still needed. Keep the explicit allowPrivateAddress and userAgent guard intact while avoiding that guard for the benchmark default. #787 (comment) #787 (comment) Assisted-by: Codex:gpt-5.5
1 parent 9989d6d commit d67d80d

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

packages/fedify/src/federation/middleware.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,19 @@ test("createFederation()", async (t) => {
148148
assertEquals(federation.allowPrivateAddress, false);
149149
});
150150

151+
await t.step(
152+
"benchmarkMode keeps private-address default with auth loader only",
153+
() => {
154+
const federation = createFederation<number>({
155+
kv,
156+
benchmarkMode: true,
157+
authenticatedDocumentLoaderFactory: () => mockDocumentLoader,
158+
});
159+
assertInstanceOf(federation, FederationImpl);
160+
assertEquals(federation.allowPrivateAddress, true);
161+
},
162+
);
163+
151164
await t.step("benchmarkMode rejects an explicit meterProvider", () => {
152165
const [meterProvider] = createTestMeterProvider();
153166
assertThrows(

packages/fedify/src/federation/middleware.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,7 @@ export class FederationImpl<TContextData>
473473
super();
474474
const benchmarkMode = options.benchmarkMode ?? false;
475475
const hasCustomLoaderFactory = options.documentLoaderFactory != null ||
476-
options.contextLoaderFactory != null ||
477-
options.authenticatedDocumentLoaderFactory != null;
476+
options.contextLoaderFactory != null;
478477
const allowPrivateAddress = options.allowPrivateAddress ??
479478
(benchmarkMode && !hasCustomLoaderFactory ? true : false);
480479
const signatureTimeWindow = options.signatureTimeWindow ??
@@ -599,7 +598,7 @@ export class FederationImpl<TContextData>
599598
this.router.trailingSlashInsensitive = options.trailingSlashInsensitive ??
600599
false;
601600
this._initializeRouter();
602-
if (allowPrivateAddress || options.userAgent != null) {
601+
if (options.allowPrivateAddress === true || options.userAgent != null) {
603602
if (options.documentLoaderFactory != null) {
604603
throw new TypeError(
605604
"Cannot set documentLoaderFactory with allowPrivateAddress or " +

0 commit comments

Comments
 (0)