Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (codex): only a CANCELED navigation clears the pending gate

[._.]/ Adam Eivye519fee3fd55
diff --git a/server/services/browserService.js b/server/services/browserService.js
index b029b94db4..63e10ce28d 100644
--- a/server/services/browserService.js
+++ b/server/services/browserService.js
@@ -321,6 +321,16 @@ export function hopMadeNoConnection(hop) {
|| NO_NETWORK_SW_SOURCES.has(hop.serviceWorkerResponseSource);
}
+// True when a `Network.loadingFailed` describes a load Chrome ABANDONED rather
+// than one that failed against a peer. Chrome 150 flags a superseded top-level
+// navigation with `canceled: true` and `net::ERR_ABORTED`; either signal alone
+// is accepted so a Chrome that reports only one of them still classifies. Every
+// other error kind is a real connection outcome we could not pin. Exported for
+// testing.
+export function navigationWasCanceled(params) {
+ return params?.canceled === true || params?.errorText === 'net::ERR_ABORTED';
+}
+
// Human-readable cause for an empty-IP refusal, so the next occurrence is
// diagnosable from the thrown message without a manual CDP replay.
const describeHopDelivery = (hop) => `no remoteIPAddress; fromServiceWorker=${hop.fromServiceWorker === true}`
@@ -360,10 +370,12 @@ const describeHopDelivery = (hop) => `no remoteIPAddress; fromServiceWorker=${ho
* whose final connection IP was never observed. The caller must fail closed on a
* non-empty pending set: Chrome could complete that navigation (to a private /
* metadata target) right after we stop capturing, leaving it unpinned. A
- * navigation Chrome reported as FAILED (`Network.loadingFailed` — most often
- * `net::ERR_ABORTED` when a client-side route change supersedes an in-flight
- * one) is NOT pending: it is dead, it can never commit a document, and there is
- * no connection left to complete after we stop capturing.
+ * navigation Chrome reported as CANCELED (`Network.loadingFailed` with
+ * `canceled`/`net::ERR_ABORTED` — what a client-side route change that
+ * supersedes an in-flight one produces) is NOT pending: it was abandoned before
+ * any answer, so nothing commits and no connection outcome is hidden. Any other
+ * failure kind stays pending and keeps failing closed — see
+ * `navigationWasCanceled`.
*/
export function pickMainFrameHops(messages, topFrameId = null) {
// CDP sets `requestId === loaderId` on the main resource of EVERY frame — the
@@ -406,10 +418,17 @@ export function pickMainFrameHops(messages, topFrameId = null) {
finalUrl = p.response.url || finalUrl;
}
} else if (msg.method === 'Network.loadingFailed' && mainRequestIds.has(p.requestId)) {
- // Chrome gave up on this load — no document will ever commit from it. A
- // failure that arrives AFTER the response is only the body being cut
- // short, and that hop is already pinned, so `respondedIds` still wins.
- failedIds.add(p.requestId);
+ // ONLY a navigation Chrome CANCELED clears the pending gate. A cancel is
+ // "this load was abandoned before any answer" — nothing committed and no
+ // connection outcome is being hidden. Every OTHER failure kind
+ // (ERR_CONNECTION_RESET, ERR_CONNECTION_REFUSED, …) means Chrome did
+ // reach out and got something back, and `loadingFailed` carries no
+ // `remoteIPAddress`, so we cannot verify WHERE — a private endpoint that
+ // accepts and resets would otherwise pass unpinned. Those stay pending
+ // and the gate keeps failing closed on them.
+ // A failure arriving AFTER the response is only a truncated body, and
+ // that hop is already pinned, so `respondedIds` still wins either way.
+ if (navigationWasCanceled(p)) failedIds.add(p.requestId);
}
}
const pendingMainRequestIds = [...mainRequestIds]
diff --git a/server/services/browserService.test.js b/server/services/browserService.test.js
index 9a1da46112..218a0fd248 100644
--- a/server/services/browserService.test.js
+++ b/server/services/browserService.test.js
@@ -273,6 +273,27 @@ describe('hopMadeNoConnection (no-network delivery classifier)', () => {
});
});
+describe('navigationWasCanceled (abandoned vs failed-against-a-peer)', () => {
+ let navigationWasCanceled;
+ beforeEach(async () => {
+ vi.resetModules();
+ ({ navigationWasCanceled } = await import('./browserService.js'));
+ });
+
+ it('accepts either cancel signal alone, and nothing else', () => {
+ // Chrome 150 sends both on a superseded navigation, but taking either alone
+ // keeps the classification working if a build reports only one.
+ expect(navigationWasCanceled({ canceled: true, errorText: 'net::ERR_ABORTED' })).toBe(true);
+ expect(navigationWasCanceled({ canceled: true, errorText: 'net::ERR_FAILED' })).toBe(true);
+ expect(navigationWasCanceled({ canceled: false, errorText: 'net::ERR_ABORTED' })).toBe(true);
+ // A real connection outcome we could not pin — never treated as abandoned.
+ expect(navigationWasCanceled({ canceled: false, errorText: 'net::ERR_CONNECTION_RESET' })).toBe(false);
+ expect(navigationWasCanceled({ errorText: 'net::ERR_CONNECTION_REFUSED' })).toBe(false);
+ expect(navigationWasCanceled({})).toBe(false);
+ expect(navigationWasCanceled(null)).toBe(false);
+ });
+});
+
describe('ssrfPinRefusalReason (SSRF pin gate)', () => {
let ssrfPinRefusalReason;
beforeEach(async () => {
@@ -347,6 +368,21 @@ describe('ssrfPinRefusalReason (SSRF pin gate)', () => {
expect(reason).toMatch(/disallowed address 127\.0\.0\.1/);
});
+ // The relaxation is scoped to CANCELED loads. A connection-level failure means
+ // Chrome DID reach a peer and got an answer back, and loadingFailed carries no
+ // remoteIPAddress — so a private endpoint that accepts and resets must not be
+ // able to retire itself from the gate by failing.
+ it('still refuses a navigation that failed against a peer rather than being canceled', () => {
+ const reason = ssrfPinRefusalReason([
+ docRequest('R1', 'https://ex.com/a'),
+ docResponse('R1', 'https://ex.com/a', '93.184.216.34'),
+ docRequest('R2', 'https://rebind.example/x'),
+ loadingFailed('R2', 'net::ERR_CONNECTION_RESET'),
+ ], allow, 'https://ex.com/a');
+ expect(reason).toMatch(/still in flight/);
+ expect(reason).toContain('https://rebind.example/x');
+ });
+
it('refuses when no main-frame document response was observed', () => {
expect(ssrfPinRefusalReason([], allow, 'https://ex.com/a')).toMatch(/no main-frame document response/);
});