synabun 2.4.6 → 2.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +1 -1
- package/mcp-server/package-lock.json +2 -2
- package/mcp-server/package.json +1 -1
- package/neural-interface/i18n/en.json +18 -0
- package/neural-interface/i18n/pt-BR.json +18 -0
- package/neural-interface/lib/browser-background-tab.js +12 -0
- package/neural-interface/lib/browser-guard-cdp.js +2 -1
- package/neural-interface/lib/browser-network-guard.js +140 -3
- package/neural-interface/lib/browser-own-targets.js +350 -0
- package/neural-interface/lib/launch-block-api.js +86 -0
- package/neural-interface/lib/morelogin-launch-recovery.js +506 -0
- package/neural-interface/lib/morelogin-profile-failures.js +48 -1
- package/neural-interface/lib/morelogin.js +16 -2
- package/neural-interface/package-lock.json +2 -2
- package/neural-interface/package.json +1 -1
- package/neural-interface/public/shared/launch-block-view.js +124 -0
- package/neural-interface/public/shared/styles.css +17 -0
- package/neural-interface/public/shared/ui-launch-block-notice.js +155 -0
- package/neural-interface/public/shared/ui-navbar.js +11 -0
- package/neural-interface/public/shared/ui-sync.js +2 -0
- package/neural-interface/server.js +429 -18
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
# SynaBun v.2.4.7
|
|
2
|
+
|
|
3
|
+
This release fixes scheduled runs that kept failing on a MoreLogin profile after one of its tabs froze. SynaBun now cleans up its own frozen tabs, recovers the profile by itself where it safely can, and tells you when a profile's launches keep failing.
|
|
4
|
+
|
|
5
|
+
## 🛠 Fixed
|
|
6
|
+
|
|
7
|
+
- **A frozen tab no longer blocks a MoreLogin profile.** When a tab SynaBun had opened stopped answering, every later scheduled run on that profile could fail at launch with a "Network guard" timeout until you stopped the profile by hand. SynaBun now closes the tabs it opened for a session that stopped answering, and closes a frozen tab it left behind the next time it connects to the profile. Tabs you opened yourself are never closed.
|
|
8
|
+
- **A blocked profile is restarted once, then retried.** When a scheduled run or a loop cannot start because the profile's browser does not answer, SynaBun restarts that profile once and tries again. It does not restart a profile that another automation is working in or that you have open in SynaBun, never switches to another profile or browser, and restarts a profile at most three times in 24 hours so it does not use up your MoreLogin daily launches.
|
|
9
|
+
- **You are told when a profile keeps failing.** After two failed launches in a row on the same profile, SynaBun shows one notice with the profile, the runs that failed, the error, what SynaBun already tried and how to fix it. The notice goes away when a launch on that profile works again or when you dismiss it.
|
|
10
|
+
- **Other runs keep their tabs.** When one run's tab fails, SynaBun closes only that run's tabs. Tabs that belong to other runs in the same browser session, which may be in the middle of an upload, stay open.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
1
14
|
# SynaBun v.2.4.6
|
|
2
15
|
|
|
3
16
|
Agents Studio gets a Work view that gathers everything your workers need from you. This release also fixes a Safari web app that kept showing "Connection Failed", Claude Code signing out on Windows, and long freezes when opening large Codex threads.
|
package/README.md
CHANGED
|
@@ -178,7 +178,7 @@ Everything SynaBun stores is in one folder outside the app: `~/.synabun` on macO
|
|
|
178
178
|
|
|
179
179
|
## Links
|
|
180
180
|
|
|
181
|
-
- [Changelog](./CHANGELOG.md): what is new in 2.4.
|
|
181
|
+
- [Changelog](./CHANGELOG.md): what is new in 2.4.7 and before
|
|
182
182
|
- [Security](./SECURITY.md): security model and how to report a vulnerability
|
|
183
183
|
- [Contributing](./CONTRIBUTING.md): bug reports and feature requests are welcome as [issues](https://github.com/danilokhury/Synabun/issues); pull requests are not accepted
|
|
184
184
|
- [Website](https://synabun.ai), [docs](https://synabun.ai/docs) and [blog](https://synabun.ai/blog)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-memory-mcp",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.7",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "claude-memory-mcp",
|
|
9
|
-
"version": "2.4.
|
|
9
|
+
"version": "2.4.7",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@huggingface/transformers": "^3.0.0",
|
package/mcp-server/package.json
CHANGED
|
@@ -14254,6 +14254,24 @@
|
|
|
14254
14254
|
"kindKilled": "ended by force",
|
|
14255
14255
|
"kindInterrupted": "interrupted"
|
|
14256
14256
|
},
|
|
14257
|
+
"launchBlock": {
|
|
14258
|
+
"label": "Runs keep failing to start in a browser profile",
|
|
14259
|
+
"title": "Runs in {profile} keep failing to start.",
|
|
14260
|
+
"countToday": "{count} launches in a row failed, the last at {time}.",
|
|
14261
|
+
"countEarlier": "{count} launches in a row failed, the last on {date} at {time}.",
|
|
14262
|
+
"launches": "Last affected: {names}.",
|
|
14263
|
+
"errorTitle": "What the browser answered",
|
|
14264
|
+
"restartedFailed": "SynaBun restarted the profile once at {time} and the next launch failed too.",
|
|
14265
|
+
"restartFailed": "SynaBun tried to restart the profile at {time} and could not.",
|
|
14266
|
+
"notRestarted": "SynaBun did not restart the profile.",
|
|
14267
|
+
"fixTitle": "How to fix it",
|
|
14268
|
+
"fixRestart": "Stop the profile and start it again, in MoreLogin or in Settings → Connected tools → MoreLogin. If the tab the error names opens again and freezes, close it.",
|
|
14269
|
+
"fixStartLimit": "MoreLogin allows no more starts of this profile today. Wait for its daily reset, raise the plan, or keep the profile open so runs need no new start.",
|
|
14270
|
+
"fixCheck": "Check the profile in MoreLogin or in Settings → Connected tools → MoreLogin: that it still exists, that MoreLogin is open, and that it starts.",
|
|
14271
|
+
"profileNamed": "\"{name}\"",
|
|
14272
|
+
"profileById": "profile {id}",
|
|
14273
|
+
"dismiss": "Dismiss"
|
|
14274
|
+
},
|
|
14257
14275
|
"ownerAuthority": {
|
|
14258
14276
|
"peerUnavailable": "SynaBun could not check which program sent this ({reason}), so it refused to act as the owner. Reload the page to try again. If it keeps happening, start SynaBun outside any sandbox, or turn this check off with SYNABUN_PEER_IDENTITY=off in ~/.synabun/.env and restart SynaBun.",
|
|
14259
14277
|
"proxyRefused": "Your browser reaches SynaBun through {name} (pid {pid}), a proxy or relay, so SynaBun can't tell it is you and refused this. Let the browser connect directly: add localhost and 127.0.0.1 to the proxy's bypass list (macOS: System Settings › Network › your network › Details › Proxies › Bypass proxy settings for these Hosts & Domains; or the list in the proxy app or browser extension), or turn the proxy off for SynaBun, then reload."
|
|
@@ -14254,6 +14254,24 @@
|
|
|
14254
14254
|
"kindKilled": "encerrado à força",
|
|
14255
14255
|
"kindInterrupted": "interrompido"
|
|
14256
14256
|
},
|
|
14257
|
+
"launchBlock": {
|
|
14258
|
+
"label": "Execuções não conseguem iniciar em um perfil de navegador",
|
|
14259
|
+
"title": "As execuções em {profile} continuam falhando ao iniciar.",
|
|
14260
|
+
"countToday": "{count} inícios seguidos falharam, o último às {time}.",
|
|
14261
|
+
"countEarlier": "{count} inícios seguidos falharam, o último em {date} às {time}.",
|
|
14262
|
+
"launches": "Últimas afetadas: {names}.",
|
|
14263
|
+
"errorTitle": "O que o navegador respondeu",
|
|
14264
|
+
"restartedFailed": "O SynaBun reiniciou o perfil uma vez às {time} e o início seguinte também falhou.",
|
|
14265
|
+
"restartFailed": "O SynaBun tentou reiniciar o perfil às {time} e não conseguiu.",
|
|
14266
|
+
"notRestarted": "O SynaBun não reiniciou o perfil.",
|
|
14267
|
+
"fixTitle": "Como resolver",
|
|
14268
|
+
"fixRestart": "Pare o perfil e inicie-o de novo, no MoreLogin ou em Configurações → Ferramentas conectadas → MoreLogin. Se a aba citada no erro abrir de novo e travar, feche-a.",
|
|
14269
|
+
"fixStartLimit": "O MoreLogin não permite mais inícios deste perfil hoje. Aguarde a renovação diária, aumente o plano ou mantenha o perfil aberto para que as execuções não precisem de um novo início.",
|
|
14270
|
+
"fixCheck": "Verifique o perfil no MoreLogin ou em Configurações → Ferramentas conectadas → MoreLogin: se ele ainda existe, se o MoreLogin está aberto e se ele inicia.",
|
|
14271
|
+
"profileNamed": "\"{name}\"",
|
|
14272
|
+
"profileById": "perfil {id}",
|
|
14273
|
+
"dismiss": "Dispensar"
|
|
14274
|
+
},
|
|
14257
14275
|
"ownerAuthority": {
|
|
14258
14276
|
"peerUnavailable": "O SynaBun não conseguiu verificar qual programa enviou isto ({reason}), então se recusou a agir como o dono. Recarregue a página para tentar de novo. Se continuar acontecendo, inicie o SynaBun fora de qualquer sandbox, ou desative esta verificação com SYNABUN_PEER_IDENTITY=off em ~/.synabun/.env e reinicie o SynaBun.",
|
|
14259
14277
|
"proxyRefused": "Seu navegador chega ao SynaBun por meio de {name} (pid {pid}), um proxy ou relay, então o SynaBun não consegue confirmar que é você e recusou isto. Deixe o navegador se conectar diretamente: adicione localhost e 127.0.0.1 à lista de exceções do proxy (macOS: Ajustes do Sistema › Rede › sua rede › Detalhes › Proxies › Ignorar as configurações de proxy para estes Hosts e Domínios; ou a lista do app de proxy ou da extensão do navegador), ou desative o proxy para o SynaBun e recarregue a página."
|
|
@@ -41,6 +41,17 @@ function browserOf(browser, context) {
|
|
|
41
41
|
|
|
42
42
|
// The pages this module opened behind the selected tab.
|
|
43
43
|
const backgroundPages = new WeakSet();
|
|
44
|
+
// Their DevTools target ids, as Target.createTarget answered them.
|
|
45
|
+
const backgroundTargetIds = new WeakMap();
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The DevTools target id of a page: the one it was created with here, else asked of the browser (given up after
|
|
49
|
+
* `timeoutMs`; null when it does not answer). It is the browser's own name for the tab, and what a browser-level
|
|
50
|
+
* Target.closeTarget takes (lib/browser-own-targets.js).
|
|
51
|
+
*/
|
|
52
|
+
export async function pageTargetId(context, page, { timeoutMs = 2000 } = {}) {
|
|
53
|
+
return backgroundTargetIds.get(page) || targetIdOf(context, page, Date.now() + timeoutMs);
|
|
54
|
+
}
|
|
44
55
|
|
|
45
56
|
/** The CDP target id of a Playwright page, or null; given up at `until`, and a session that attaches later is detached. */
|
|
46
57
|
async function targetIdOf(context, page, until) {
|
|
@@ -104,6 +115,7 @@ export async function openBackgroundPage(browser, context, { timeoutMs = 5000, b
|
|
|
104
115
|
});
|
|
105
116
|
if (!page) throw new Error('the tab did not appear');
|
|
106
117
|
backgroundPages.add(page);
|
|
118
|
+
backgroundTargetIds.set(page, targetId);
|
|
107
119
|
return page;
|
|
108
120
|
} catch {
|
|
109
121
|
if (cdp && targetId) {
|
|
@@ -34,7 +34,8 @@ export class GuardCdpConnection extends EventEmitter {
|
|
|
34
34
|
if (this.closed || this.closing) return Promise.reject(new Error('Network guard CDP transport closed'));
|
|
35
35
|
const id = ++this.sequence;
|
|
36
36
|
return new Promise((resolve, reject) => {
|
|
37
|
-
|
|
37
|
+
// `timedOut` tells a command nobody answered from one the browser refused (lib/browser-network-guard.js reclaim).
|
|
38
|
+
const timer = setTimeout(() => { this.pending.delete(id); reject(Object.assign(new Error(`Network guard: ${method} timed out`), { timedOut: true })); }, this.timeoutMs);
|
|
38
39
|
this.pending.set(id, { resolve, reject, timer, sessionId, method });
|
|
39
40
|
const failed = error => {
|
|
40
41
|
if (!error) return;
|
|
@@ -16,6 +16,23 @@
|
|
|
16
16
|
// be installed stays paused and is retried; pages, frames, dedicated workers and
|
|
17
17
|
// targets already running still fail closed for the whole context, and a faulted
|
|
18
18
|
// context re-arms with a fresh attachment (recoverBrowserNetworkGuard).
|
|
19
|
+
//
|
|
20
|
+
// One exception to "never closes a target" (2026-11-29). A target that was already
|
|
21
|
+
// running when this client attached and never answers (a worker in `while (true)`,
|
|
22
|
+
// a frozen renderer) can never be protected, so it failed every later attachment to
|
|
23
|
+
// the profile: on 2026-11-28 two nested workers of a TikTok Studio upload tab, left
|
|
24
|
+
// behind by a retired session, failed every scheduled launch on that MoreLogin
|
|
25
|
+
// profile for 40 hours. When such a target's top-level page is a tab SynaBun opened
|
|
26
|
+
// that no live session works in (`pageOwner` answers 'orphan'), that page is closed
|
|
27
|
+
// with the browser-level Target.closeTarget, which needs no answer from its renderer
|
|
28
|
+
// and ends its frames and workers, and arming goes on. Every other page (a live
|
|
29
|
+
// session's tab, the owner's own tab, one nobody can place) still fails closed; the
|
|
30
|
+
// error then names the page and the kind of target, so the owner can find the tab.
|
|
31
|
+
// Measured in Chromium 147 (tests/browser-network-guard-orphan.browser.mjs): a worker
|
|
32
|
+
// in `while (true) {}`, in a synchronous request or in Atomics.wait never answers a
|
|
33
|
+
// NEW client's Target.setAutoAttach, but answers at once while a client that turned
|
|
34
|
+
// auto-attach on before it hung is still attached. So the session that opened the tab
|
|
35
|
+
// never sees the fault; the first attachment after that session has gone does.
|
|
19
36
|
import { connectGuardCdp } from './browser-guard-cdp.js';
|
|
20
37
|
const guards = new WeakMap();
|
|
21
38
|
const endpoints = new WeakMap();
|
|
@@ -32,13 +49,35 @@ const TIMING = {
|
|
|
32
49
|
quarantineRetryMs: [1000, 5000, 15000, 60000], // the last delay repeats while the worker exists
|
|
33
50
|
rearmBackoffMs: [2000, 5000, 15000, 30000, 60000], // after a failed re-arm; the last repeats
|
|
34
51
|
recoverTimeoutMs: 10000, // the longest a caller waits for one re-arm
|
|
52
|
+
orphanCloseMs: 5000, // how long a closed orphan tab may take to leave the browser
|
|
53
|
+
};
|
|
54
|
+
// Whose a top-level page is, as `pageOwner` answers it. Only an 'orphan' is ever closed.
|
|
55
|
+
const PAGE_OWNER_WORDS = {
|
|
56
|
+
live: 'a live SynaBun session works in that tab',
|
|
57
|
+
foreign: 'SynaBun did not open that tab (it is the owner\'s own)',
|
|
58
|
+
orphan: 'SynaBun opened that tab for a session that has ended',
|
|
59
|
+
unknown: 'SynaBun cannot tell whose tab that is',
|
|
35
60
|
};
|
|
61
|
+
/** A page address as an error and a log name it: no query and no fragment (they can carry tokens). */
|
|
62
|
+
export function guardPageLabel(url) {
|
|
63
|
+
const text = typeof url === 'string' ? url : '';
|
|
64
|
+
try {
|
|
65
|
+
const parsed = new URL(text);
|
|
66
|
+
return (/^https?:$/.test(parsed.protocol) ? `${parsed.origin}${parsed.pathname}` : `${parsed.protocol}${parsed.pathname}`).slice(0, 200);
|
|
67
|
+
} catch { return text ? text.split(/[?#]/)[0].slice(0, 200) : 'an unnamed page'; }
|
|
68
|
+
}
|
|
36
69
|
export const NETWORK_GUARD_FAULT_EVENT = 'synabun-network-guard-fault';
|
|
37
70
|
export const NETWORK_GUARD_RECOVERED_EVENT = 'synabun-network-guard-recovered';
|
|
38
71
|
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Register only externally owned Chromium contexts with an existing endpoint.
|
|
74
|
+
* `pageOwner(targetInfo)` says whose a top-level page is: 'orphan' (a tab SynaBun opened that no live session works
|
|
75
|
+
* in), 'live' (a live session's tab), 'foreign' (not SynaBun's: the owner's own tab) or 'unknown'; sync or async.
|
|
76
|
+
* Without it every page is 'unknown' and nothing is ever closed. `onOrphanClosed(targetInfo)` is told of each orphan
|
|
77
|
+
* tab the guard closed.
|
|
78
|
+
*/
|
|
79
|
+
export function registerBrowserNetworkEndpoint(context, endpoint, { connect = connectGuardCdp, timing, pageOwner = null, onOrphanClosed = null } = {}) {
|
|
80
|
+
endpoints.set(context, { endpoint, connect, timing: { ...TIMING, ...timing }, pageOwner, onOrphanClosed });
|
|
42
81
|
}
|
|
43
82
|
|
|
44
83
|
export function usesNativeBrowserNetworkGuard(context) { return endpoints.has(context); }
|
|
@@ -50,6 +89,8 @@ class GuardLink {
|
|
|
50
89
|
this.children = new Map();
|
|
51
90
|
this.installing = new Set();
|
|
52
91
|
this.timers = new Set();
|
|
92
|
+
this.reclaims = new Map(); // page targetId → the one attempt of this link to close that orphan page
|
|
93
|
+
this.destroyed = new Set(); // targetIds the browser reported destroyed (Target.targetDestroyed) on this link
|
|
53
94
|
this.fault = null;
|
|
54
95
|
this.closed = false;
|
|
55
96
|
}
|
|
@@ -154,6 +195,92 @@ class GuardLink {
|
|
|
154
195
|
this.resume(child);
|
|
155
196
|
});
|
|
156
197
|
}
|
|
198
|
+
/** The top-level page a target lives in (itself, for a page), or null: a service or shared worker has none. */
|
|
199
|
+
topPage(child) {
|
|
200
|
+
let node = child;
|
|
201
|
+
while (node?.parent && node.parent !== this.root) node = node.parent;
|
|
202
|
+
return node?.target?.type === 'page' && node.parent === this.root ? node : null;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* A target that was already running and whose protection nobody answered: whose page it is in, and that page
|
|
206
|
+
* closed when it is an orphan. One attempt per page for this link, shared by every target under it (a frozen tab
|
|
207
|
+
* can hold dozens of workers). → { closed, owner, page: { targetId, url, type } | null }. Never rejects.
|
|
208
|
+
*/
|
|
209
|
+
reclaim(child) {
|
|
210
|
+
const page = this.topPage(child);
|
|
211
|
+
if (!page) return Promise.resolve({ closed: false, owner: 'unknown', page: null });
|
|
212
|
+
const targetId = page.target.targetId;
|
|
213
|
+
if (!this.reclaims.has(targetId)) {
|
|
214
|
+
this.reclaims.set(targetId, this.closeOrphan(page).catch(() => ({ closed: false, owner: 'unknown', page: { targetId, url: page.target.url || '', type: 'page' } })));
|
|
215
|
+
}
|
|
216
|
+
return this.reclaims.get(targetId);
|
|
217
|
+
}
|
|
218
|
+
async closeOrphan(page) {
|
|
219
|
+
const targetId = page.target.targetId;
|
|
220
|
+
// Asked of the browser, not of the page: it answers for a frozen renderer too, and with the address of now.
|
|
221
|
+
let info = page.target;
|
|
222
|
+
try { info = (await this.root.send('Target.getTargetInfo', { targetId })).targetInfo || info; } catch { /* as attached */ }
|
|
223
|
+
const { pageOwner, onOrphanClosed } = endpoints.get(this.guard.context) || {};
|
|
224
|
+
let owner = 'unknown';
|
|
225
|
+
try {
|
|
226
|
+
const said = typeof pageOwner === 'function' ? await pageOwner({ ...info }) : null;
|
|
227
|
+
if (said === 'orphan' || said === 'live' || said === 'foreign') owner = said;
|
|
228
|
+
} catch { owner = 'unknown'; }
|
|
229
|
+
const out = { closed: false, owner, page: { targetId, url: info.url || '', type: info.type || 'page' } };
|
|
230
|
+
if (owner !== 'orphan' || this.closed) return out;
|
|
231
|
+
console.warn(`[browser-network-guard] closing the orphan tab ${guardPageLabel(info.url)} (target ${targetId}): a target in it does not answer, SynaBun opened it and no live session works in it`);
|
|
232
|
+
try { await this.root.send('Target.closeTarget', { targetId }); }
|
|
233
|
+
catch (error) {
|
|
234
|
+
if (!gone(error) && !/No target with given id/i.test(error.protocolMessage || error.message)) {
|
|
235
|
+
console.error(`[browser-network-guard] the orphan tab ${guardPageLabel(info.url)} (target ${targetId}) could not be closed: ${error.message}`);
|
|
236
|
+
return out;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
// Closed when the browser says so: Target.targetDestroyed seen for it, or Target.getTargetInfo no longer knows it.
|
|
240
|
+
// The detach of the page's own session (Target.detachedFromTarget) comes with a close too, often first, but a
|
|
241
|
+
// session also detaches for other reasons while its tab runs on (and its worker with it): a detach alone is no
|
|
242
|
+
// close, it only makes the browser be asked at once. Each question is bounded by what is left of orphanCloseMs, so
|
|
243
|
+
// a browser that does not answer cannot hold the arming up; past it the page is not closed and arming fails closed.
|
|
244
|
+
const until = Date.now() + this.guard.timing.orphanCloseMs;
|
|
245
|
+
for (;;) {
|
|
246
|
+
if (this.closed) return out;
|
|
247
|
+
let left = this.destroyed.has(targetId);
|
|
248
|
+
if (!left) {
|
|
249
|
+
const wait = Math.max(1, until - Date.now());
|
|
250
|
+
let timer;
|
|
251
|
+
const unanswered = new Promise(resolve => { timer = setTimeout(() => resolve('unanswered'), wait); timer.unref?.(); });
|
|
252
|
+
const asked = this.root.send('Target.getTargetInfo', { targetId }).then(
|
|
253
|
+
reply => (reply?.targetInfo ? 'open' : 'gone'),
|
|
254
|
+
probe => (/No target with given id/i.test(probe.protocolMessage || probe.message) ? 'gone' : 'unanswered'),
|
|
255
|
+
);
|
|
256
|
+
const said = await Promise.race([asked, unanswered]).finally(() => clearTimeout(timer));
|
|
257
|
+
left = said === 'gone' || this.destroyed.has(targetId);
|
|
258
|
+
}
|
|
259
|
+
if (left) break;
|
|
260
|
+
if (Date.now() >= until) {
|
|
261
|
+
console.error(`[browser-network-guard] the orphan tab ${guardPageLabel(info.url)} (target ${targetId}) is still open ${this.guard.timing.orphanCloseMs} ms after it was closed`);
|
|
262
|
+
return out;
|
|
263
|
+
}
|
|
264
|
+
await new Promise(resolve => { const timer = setTimeout(resolve, 50); timer.unref?.(); });
|
|
265
|
+
}
|
|
266
|
+
out.closed = true;
|
|
267
|
+
console.warn(`[browser-network-guard] closed the orphan tab ${guardPageLabel(info.url)} (target ${targetId}); arming goes on`);
|
|
268
|
+
try { onOrphanClosed?.({ ...info }); } catch { /* the registry's own business */ }
|
|
269
|
+
return out;
|
|
270
|
+
}
|
|
271
|
+
/** The fail-closed error of a running target nobody answered for, naming its page and what kind of target it is. */
|
|
272
|
+
named(error, child, outcome) {
|
|
273
|
+
// A worker fails with its parent's own error when the parent could not be configured: named once, as the parent's.
|
|
274
|
+
if (error.pageOwner) return error;
|
|
275
|
+
const where = outcome.page;
|
|
276
|
+
const label = where ? guardPageLabel(where.url) : null;
|
|
277
|
+
const kind = child.target.type === 'page' ? 'the page itself' : `a ${child.target.type} in it`;
|
|
278
|
+
error.message = where
|
|
279
|
+
? `${error.message}. The target that does not answer is in the tab ${label} (${kind}); ${PAGE_OWNER_WORDS[outcome.owner]}${outcome.owner === 'orphan' ? ' and could not close it' : ', so SynaBun did not close it'}`
|
|
280
|
+
: `${error.message}. The target that does not answer is a ${child.target.type}${child.target.url ? ` of ${guardPageLabel(child.target.url)}` : ''} with no tab of its own to close`;
|
|
281
|
+
Object.assign(error, { pageOwner: outcome.owner, ...(where ? { pageUrl: label, pageTargetId: where.targetId } : {}) });
|
|
282
|
+
return error;
|
|
283
|
+
}
|
|
157
284
|
async ownsDocument(frameId) {
|
|
158
285
|
try {
|
|
159
286
|
const { targetInfo } = await this.root.send('Target.getTargetInfo', { targetId: frameId });
|
|
@@ -204,6 +331,9 @@ class GuardLink {
|
|
|
204
331
|
} else if (method === 'Target.detachedFromTarget') {
|
|
205
332
|
this.children.get(event.sessionId)?.close();
|
|
206
333
|
this.children.delete(event.sessionId);
|
|
334
|
+
} else if (method === 'Target.targetDestroyed') {
|
|
335
|
+
// Only an orphan close waits for this (closeOrphan); kept for the pages it asked about, so it stays small.
|
|
336
|
+
if (event?.targetId && this.reclaims.has(event.targetId)) this.destroyed.add(event.targetId);
|
|
207
337
|
} else if (method === 'Fetch.requestPaused') {
|
|
208
338
|
if (!parent) return; // event queued before this target's detach arrived
|
|
209
339
|
void this.request(parent, event).catch(error => {
|
|
@@ -234,6 +364,13 @@ class GuardLink {
|
|
|
234
364
|
} catch (error) {
|
|
235
365
|
if (await this.vanished(child, error)) return;
|
|
236
366
|
if (waiting && OWN_FETCH_WORKERS.has(child.target.type)) { this.quarantine(child, error); return; }
|
|
367
|
+
// A target that already ran and never answered: no retry protects it. When its page is an orphan tab of
|
|
368
|
+
// SynaBun's, the page is closed (its workers and frames end with it) and arming goes on.
|
|
369
|
+
if (!waiting && error?.timedOut) {
|
|
370
|
+
const outcome = await this.reclaim(child);
|
|
371
|
+
if (outcome.closed || this.closed) return;
|
|
372
|
+
throw this.named(error, child, outcome);
|
|
373
|
+
}
|
|
237
374
|
// Pages, frames, dedicated workers and anything already running fail closed.
|
|
238
375
|
throw error;
|
|
239
376
|
}
|