Skip to content

Commit 29a21a9

Browse files
committed
fix(linux): ignore auto-attach events on unrestricted hosts
Target.attachedToTarget also fires for attachToTarget. Closing extra page targets in that path would kill the agent session when no allowlist is set.
1 parent b65a381 commit 29a21a9

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

apps/headless/LinuxHost/BrowserProcess.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,12 @@ final class ChromiumProcess {
365365
private func routeEvent(_ event: [String: Any]) {
366366
let method = event["method"] as? String
367367
if method == "Target.attachedToTarget" {
368-
handleAttachedToTarget(event)
368+
// Auto-attach is only enabled for a restricted allowlist. Ignoring
369+
// this event on an unrestricted host keeps attachToTarget from
370+
// closing the agent page it just created.
371+
if processNavigationAllowlist.isRestricted {
372+
handleAttachedToTarget(event)
373+
}
369374
return
370375
}
371376
let sessionID = event["sessionId"] as? String
@@ -438,6 +443,7 @@ final class ChromiumProcess {
438443
}
439444

440445
private func handleAttachedToTarget(_ event: [String: Any]) {
446+
guard processNavigationAllowlist.isRestricted else { return }
441447
guard let parameters = event["params"] as? [String: Any],
442448
let sessionID = parameters["sessionId"] as? String,
443449
let targetInfo = parameters["targetInfo"] as? [String: Any],

0 commit comments

Comments
 (0)