browser-debugger-cli 0.13.0 → 0.15.0
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/.claude/skills/bdg/SKILL.md +101 -187
- package/README.md +4 -4
- package/dist/commands/cdp.js +1 -0
- package/dist/commands/cleanup.js +3 -0
- package/dist/commands/console.js +5 -1
- package/dist/commands/dom/a11y.d.ts +1 -1
- package/dist/commands/dom/a11y.js +20 -20
- package/dist/commands/dom/eval.d.ts +3 -1
- package/dist/commands/dom/eval.js +8 -5
- package/dist/commands/dom/formInteraction.js +1 -1
- package/dist/commands/dom/get.js +25 -7
- package/dist/commands/dom/helpers/evalResult.d.ts +36 -0
- package/dist/commands/dom/helpers/evalResult.js +59 -0
- package/dist/commands/dom/index.js +7 -2
- package/dist/commands/dom/query.d.ts +2 -1
- package/dist/commands/dom/query.js +5 -3
- package/dist/commands/dom/screenshot.js +1 -0
- package/dist/commands/helpJson.d.ts +1 -1
- package/dist/commands/helpJson.js +4 -4
- package/dist/commands/helpTopic.js +10 -4
- package/dist/commands/network/har.js +18 -14
- package/dist/commands/network/list.js +46 -3
- package/dist/commands/optionBehaviors.d.ts +25 -2
- package/dist/commands/optionBehaviors.js +60 -42
- package/dist/commands/peek.js +3 -0
- package/dist/commands/shared/CommandRunner.js +13 -13
- package/dist/commands/shared/daemonErrorHandler.js +2 -2
- package/dist/commands/shared/dataFetcher.d.ts +4 -2
- package/dist/commands/shared/dataFetcher.js +11 -3
- package/dist/commands/shared/handleValidationError.js +3 -3
- package/dist/commands/shared/optionTypes.d.ts +15 -3
- package/dist/commands/shared/outputFile.d.ts +2 -1
- package/dist/commands/shared/outputFile.js +7 -4
- package/dist/commands/shared/startHelpers.js +3 -3
- package/dist/commands/status.js +3 -1
- package/dist/commands/stop.js +2 -1
- package/dist/connection/chromeIdentity.d.ts +8 -2
- package/dist/connection/chromeIdentity.js +85 -13
- package/dist/connection/launcher/flagsBuilder.d.ts +46 -0
- package/dist/connection/launcher/flagsBuilder.js +107 -23
- package/dist/connection/launcher.d.ts +1 -1
- package/dist/connection/launcher.js +1 -2
- package/dist/constants.d.ts +31 -5
- package/dist/constants.js +37 -5
- package/dist/daemon/SessionController.js +2 -0
- package/dist/daemon/launcher.d.ts +17 -3
- package/dist/daemon/launcher.js +37 -7
- package/dist/daemon/session/Session.d.ts +2 -1
- package/dist/daemon/session/Session.js +10 -2
- package/dist/daemon/session/TelemetryStore.d.ts +7 -0
- package/dist/daemon/session/TelemetryStore.js +6 -0
- package/dist/daemon/session/commandRegistry.js +25 -7
- package/dist/daemon/session/matchedStylesReset.d.ts +26 -0
- package/dist/daemon/session/matchedStylesReset.js +46 -0
- package/dist/daemon/session/plugins.js +1 -0
- package/dist/daemon/session/triggeredRequests.d.ts +0 -5
- package/dist/daemon/session/triggeredRequests.js +13 -7
- package/dist/daemon.js +8742 -8315
- package/dist/errors/messages.d.ts +31 -0
- package/dist/errors/messages.js +96 -6
- package/dist/index.js +1129 -548
- package/dist/ipc/client.d.ts +6 -1
- package/dist/ipc/client.js +11 -2
- package/dist/ipc/protocol/commands.d.ts +8 -0
- package/dist/ipc/protocol/inspectTypes.d.ts +5 -2
- package/dist/ipc/session/types.d.ts +5 -1
- package/dist/ipc/transport/index.d.ts +6 -0
- package/dist/ipc/transport/index.js +16 -1
- package/dist/program.d.ts +14 -0
- package/dist/program.js +53 -0
- package/dist/runtime/dom/elementGeometry.d.ts +23 -0
- package/dist/runtime/dom/elementGeometry.js +17 -15
- package/dist/runtime/dom/elementInfo.d.ts +13 -4
- package/dist/runtime/dom/elementInfo.js +15 -5
- package/dist/runtime/dom/evalHelpers.d.ts +24 -4
- package/dist/runtime/dom/evalHelpers.js +40 -12
- package/dist/runtime/dom/frameScopedConnection.d.ts +7 -0
- package/dist/runtime/dom/frameScopedConnection.js +2 -2
- package/dist/runtime/dom/frames.d.ts +2 -1
- package/dist/runtime/dom/frames.js +3 -1
- package/dist/runtime/dom/inspect.d.ts +17 -3
- package/dist/runtime/dom/inspect.js +40 -26
- package/dist/runtime/dom/inspectModel.d.ts +3 -3
- package/dist/runtime/dom/inspectRules.d.ts +29 -3
- package/dist/runtime/dom/inspectRules.js +205 -11
- package/dist/runtime/dom/layout.d.ts +0 -2
- package/dist/runtime/dom/layout.js +1 -2
- package/dist/runtime/dom/reactEventHelpers.d.ts +4 -1
- package/dist/runtime/dom/reactEventHelpers.js +9 -2
- package/dist/runtime/dom/targetNode.d.ts +10 -6
- package/dist/runtime/dom/targetNode.js +15 -8
- package/dist/runtime/page/emulation.js +6 -5
- package/dist/runtime/page/userAgent.d.ts +86 -2
- package/dist/runtime/page/userAgent.js +154 -33
- package/dist/session/paths.d.ts +38 -3
- package/dist/session/paths.js +154 -7
- package/dist/session/portClaims.d.ts +0 -8
- package/dist/session/portClaims.js +1 -22
- package/dist/session/sessionList.d.ts +5 -1
- package/dist/session/sessionList.js +5 -1
- package/dist/telemetry/a11y.d.ts +15 -1
- package/dist/telemetry/a11y.js +83 -0
- package/dist/telemetry/har/builder.d.ts +12 -1
- package/dist/telemetry/har/builder.js +11 -3
- package/dist/telemetry/har/sanitize.d.ts +24 -0
- package/dist/telemetry/har/sanitize.js +138 -0
- package/dist/telemetry/har/sanitizeBody.d.ts +38 -0
- package/dist/telemetry/har/sanitizeBody.js +168 -0
- package/dist/telemetry/network.d.ts +13 -16
- package/dist/telemetry/network.js +30 -52
- package/dist/telemetry/networkRetention.d.ts +83 -0
- package/dist/telemetry/networkRetention.js +117 -0
- package/dist/types.d.ts +26 -0
- package/dist/ui/OutputBuilder.d.ts +10 -0
- package/dist/ui/OutputBuilder.js +12 -0
- package/dist/ui/formatters/a11y.d.ts +5 -7
- package/dist/ui/formatters/a11y.js +7 -61
- package/dist/ui/formatters/console/chronological.js +4 -4
- package/dist/ui/formatters/console/follow.d.ts +4 -2
- package/dist/ui/formatters/console/follow.js +6 -3
- package/dist/ui/formatters/console/json.d.ts +3 -6
- package/dist/ui/formatters/console/json.js +9 -13
- package/dist/ui/formatters/console/shared.d.ts +17 -2
- package/dist/ui/formatters/console/shared.js +17 -0
- package/dist/ui/formatters/console/summarize.d.ts +2 -2
- package/dist/ui/formatters/console/summarize.js +22 -7
- package/dist/ui/formatters/console.d.ts +1 -1
- package/dist/ui/formatters/console.js +1 -5
- package/dist/ui/formatters/details.js +1 -1
- package/dist/ui/formatters/dom.d.ts +13 -4
- package/dist/ui/formatters/dom.js +25 -7
- package/dist/ui/formatters/layout.js +2 -1
- package/dist/ui/formatters/longValues.d.ts +14 -0
- package/dist/ui/formatters/longValues.js +23 -0
- package/dist/ui/formatters/networkList.d.ts +8 -2
- package/dist/ui/formatters/networkList.js +11 -2
- package/dist/ui/formatters/preview.d.ts +4 -1
- package/dist/ui/formatters/preview.js +55 -13
- package/dist/ui/formatters/sessions.d.ts +3 -2
- package/dist/ui/formatters/sessions.js +10 -3
- package/dist/ui/formatters/status.js +7 -0
- package/dist/ui/formatters/triggeredRequests.js +2 -1
- package/dist/ui/messages/chrome.d.ts +34 -7
- package/dist/ui/messages/chrome.js +81 -15
- package/dist/ui/messages/commands.d.ts +29 -8
- package/dist/ui/messages/commands.js +36 -8
- package/dist/ui/messages/networkMessages.d.ts +50 -0
- package/dist/ui/messages/networkMessages.js +66 -0
- package/dist/ui/messages/session.d.ts +8 -0
- package/dist/ui/messages/session.js +10 -0
- package/dist/utils/atomicFile.d.ts +2 -1
- package/dist/utils/atomicFile.js +5 -2
- package/dist/utils/directories.d.ts +41 -0
- package/dist/utils/directories.js +48 -0
- package/dist/utils/http.d.ts +9 -2
- package/dist/utils/http.js +4 -3
- package/dist/utils/strings.d.ts +19 -0
- package/dist/utils/strings.js +16 -0
- package/package.json +2 -2
|
@@ -11,8 +11,10 @@ import { connectCDP, navigateToTarget } from './cdpSetup.js';
|
|
|
11
11
|
import { externalChromePort, findPageTarget, setupChromeConnection, } from './chromeConnection.js';
|
|
12
12
|
import { startTelemetryCollectors } from './collectors.js';
|
|
13
13
|
import { createCommandRegistry } from './commandRegistry.js';
|
|
14
|
+
import { withMatchedStylesReset } from './matchedStylesReset.js';
|
|
14
15
|
import { teardownSession } from './teardown.js';
|
|
15
16
|
import { CommandError } from '../../errors/index.js';
|
|
17
|
+
import { unknownSessionCommandMessage } from '../../errors/messages.js';
|
|
16
18
|
import { applySessionEmulation } from '../../runtime/page/emulation.js';
|
|
17
19
|
import { readPageLoadingState } from '../../runtime/page/loadingState.js';
|
|
18
20
|
import { reapOrphanedChrome, removeSessionFiles } from '../../session/cleanup/staleSession.js';
|
|
@@ -151,7 +153,8 @@ export class Session {
|
|
|
151
153
|
* Execute a registered command against this session. After a renderer
|
|
152
154
|
* crash only {@link RUN_ON_CRASHED_PAGE} commands run (`bdg cdp` only for
|
|
153
155
|
* {@link CRASH_SAFE_CDP} methods); others fail with exit 107 instead of
|
|
154
|
-
* waiting for a page that cannot answer.
|
|
156
|
+
* waiting for a page that cannot answer. Commands that may change the page
|
|
157
|
+
* drop `dom inspect`'s kept matched rules ({@link withMatchedStylesReset}).
|
|
155
158
|
*
|
|
156
159
|
* @param name - Command name
|
|
157
160
|
* @param params - Command parameters
|
|
@@ -168,7 +171,12 @@ export class Session {
|
|
|
168
171
|
if (crashedAt !== undefined && needsPage) {
|
|
169
172
|
return Promise.reject(pageCrashedCommandError(crashedAt));
|
|
170
173
|
}
|
|
171
|
-
|
|
174
|
+
if (!Object.hasOwn(this.registry, name)) {
|
|
175
|
+
return Promise.reject(new CommandError(unknownSessionCommandMessage(name), {}, EXIT_CODES.INVALID_ARGUMENTS));
|
|
176
|
+
}
|
|
177
|
+
const handler = this.registry[name];
|
|
178
|
+
const cdp = this.cdp;
|
|
179
|
+
return withMatchedStylesReset(cdp, name, () => handler(cdp, params));
|
|
172
180
|
}
|
|
173
181
|
/**
|
|
174
182
|
* Summary of this session for start responses.
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { DialogInfo } from '../../ipc/protocol/domTypes.js';
|
|
2
2
|
import type { NavigationEvent } from '../../telemetry/navigation.js';
|
|
3
3
|
import type { PendingRequest } from '../../telemetry/network.js';
|
|
4
|
+
import type { NetworkEvictions } from '../../telemetry/networkRetention.js';
|
|
4
5
|
import type { CDPTarget, ConsoleMessage, NetworkRequest, TelemetryType, WebSocketConnection } from '../../types.js';
|
|
5
6
|
export declare class TelemetryStore {
|
|
7
|
+
/**
|
|
8
|
+
* Finished requests, oldest first: the newest are kept, so the session's
|
|
9
|
+
* `networkEvictions.requestsDropped` oldest ones are gone
|
|
10
|
+
*/
|
|
6
11
|
readonly networkRequests: NetworkRequest[];
|
|
12
|
+
/** Requests dropped and response bodies evicted at the capture limits */
|
|
13
|
+
readonly networkEvictions: NetworkEvictions;
|
|
7
14
|
/** Requests still in flight, keyed by CDP requestId */
|
|
8
15
|
readonly pendingNetworkRequests: Map<string, PendingRequest>;
|
|
9
16
|
readonly consoleMessages: ConsoleMessage[];
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { MAX_CONSOLE_MESSAGES } from '../../constants.js';
|
|
2
2
|
import { dialogConsoleText } from '../../ui/messages/commands.js';
|
|
3
3
|
export class TelemetryStore {
|
|
4
|
+
/**
|
|
5
|
+
* Finished requests, oldest first: the newest are kept, so the session's
|
|
6
|
+
* `networkEvictions.requestsDropped` oldest ones are gone
|
|
7
|
+
*/
|
|
4
8
|
networkRequests = [];
|
|
9
|
+
/** Requests dropped and response bodies evicted at the capture limits */
|
|
10
|
+
networkEvictions = { requestsDropped: 0, bodiesEvicted: 0 };
|
|
5
11
|
/** Requests still in flight, keyed by CDP requestId */
|
|
6
12
|
pendingNetworkRequests = new Map();
|
|
7
13
|
consoleMessages = [];
|
|
@@ -21,7 +21,7 @@ import { evaluateInBdgWorld, sendForBdgScript } from '../../runtime/page/bdgWorl
|
|
|
21
21
|
import { emulatePage, pageAppearance } from '../../runtime/page/emulation.js';
|
|
22
22
|
import { readDocumentReadyState } from '../../runtime/page/loadingState.js';
|
|
23
23
|
import { navigatePage } from '../../runtime/page/navigation.js';
|
|
24
|
-
import { skippedBodyReason } from '../../telemetry/
|
|
24
|
+
import { skippedBodyReason } from '../../telemetry/networkRetention.js';
|
|
25
25
|
import { consoleMessageDroppedError } from '../../ui/messages/consoleMessages.js';
|
|
26
26
|
import { sessionCommand } from '../../ui/messages/sessionCommand.js';
|
|
27
27
|
import { EXIT_CODES } from '../../utils/exitCodes.js';
|
|
@@ -140,6 +140,20 @@ function webSocketAsRequest(connection) {
|
|
|
140
140
|
webSocket: { frames: connection.frames, ...(closedTime !== undefined && { closedTime }) },
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Status activity counts of what the network capture let go at its limits,
|
|
145
|
+
* left out when nothing was.
|
|
146
|
+
*
|
|
147
|
+
* @param store - Telemetry store
|
|
148
|
+
* @returns `networkRequestsDropped` and `networkBodiesEvicted` when non-zero
|
|
149
|
+
*/
|
|
150
|
+
function networkEvictionActivity(store) {
|
|
151
|
+
const { requestsDropped, bodiesEvicted } = store.networkEvictions;
|
|
152
|
+
return {
|
|
153
|
+
...(requestsDropped > 0 && { networkRequestsDropped: requestsDropped }),
|
|
154
|
+
...(bodiesEvicted > 0 && { networkBodiesEvicted: bodiesEvicted }),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
143
157
|
/**
|
|
144
158
|
* All captured network activity: finished and in-flight requests and
|
|
145
159
|
* WebSocket connections, in start order.
|
|
@@ -319,6 +333,7 @@ export function createCommandRegistry(store, emulation) {
|
|
|
319
333
|
const totalNetwork = allNetwork.length;
|
|
320
334
|
const totalConsole = store.consoleMessages.length;
|
|
321
335
|
const dropped = store.consoleDropped;
|
|
336
|
+
const { requestsDropped, bodiesEvicted } = store.networkEvictions;
|
|
322
337
|
const networkBounds = calculateSliceBounds(totalNetwork, lastN, offset);
|
|
323
338
|
const consoleBounds = calculateSliceBounds(totalConsole, lastN, offset);
|
|
324
339
|
const recentNetwork = params.only === 'console'
|
|
@@ -347,6 +362,8 @@ export function createCommandRegistry(store, emulation) {
|
|
|
347
362
|
totalNetwork,
|
|
348
363
|
totalConsole,
|
|
349
364
|
...(dropped > 0 && { droppedConsole: dropped }),
|
|
365
|
+
...(requestsDropped > 0 && { droppedNetwork: requestsDropped }),
|
|
366
|
+
...(bodiesEvicted > 0 && { evictedNetworkBodies: bodiesEvicted }),
|
|
350
367
|
hasMoreNetwork: networkBounds.start > 0,
|
|
351
368
|
hasMoreConsole: consoleBounds.start > 0,
|
|
352
369
|
});
|
|
@@ -377,12 +394,13 @@ export function createCommandRegistry(store, emulation) {
|
|
|
377
394
|
: { crashedAt: store.pageCrashedAt }),
|
|
378
395
|
},
|
|
379
396
|
activeTelemetry: store.activeTelemetry,
|
|
380
|
-
activity:
|
|
397
|
+
activity: {
|
|
381
398
|
networkRequestsCaptured: store.networkRequests.length,
|
|
382
399
|
consoleMessagesCaptured: store.consoleMessages.length,
|
|
383
|
-
lastNetworkRequestAt: lastNetworkRequest
|
|
384
|
-
lastConsoleMessageAt: lastConsoleMessage
|
|
385
|
-
|
|
400
|
+
...(lastNetworkRequest && { lastNetworkRequestAt: lastNetworkRequest.timestamp }),
|
|
401
|
+
...(lastConsoleMessage && { lastConsoleMessageAt: lastConsoleMessage.timestamp }),
|
|
402
|
+
...networkEvictionActivity(store),
|
|
403
|
+
},
|
|
386
404
|
navigationId: store.getCurrentNavigationId?.() ?? 0,
|
|
387
405
|
};
|
|
388
406
|
return result;
|
|
@@ -434,8 +452,8 @@ export function createCommandRegistry(store, emulation) {
|
|
|
434
452
|
return { result, ...(hint !== undefined && { hint }) };
|
|
435
453
|
},
|
|
436
454
|
dom_eval: async (cdp, params) => params.frame === undefined
|
|
437
|
-
? evaluateScript(cdp, params.script)
|
|
438
|
-
: evaluateInFrame(cdp, pageWebSocketUrl(store), params.script, params.frame, listedFrameIds),
|
|
455
|
+
? evaluateScript(cdp, params.script, { full: params.full ?? false })
|
|
456
|
+
: evaluateInFrame(cdp, pageWebSocketUrl(store), params.script, params.frame, listedFrameIds, params.full ?? false),
|
|
439
457
|
dom_frames: async (cdp) => {
|
|
440
458
|
const { frames, frameIds } = await listFrames(cdp, pageWebSocketUrl(store));
|
|
441
459
|
listedFrameIds = frameIds;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dom inspect` keeps slow matched-rules answers for a few seconds, but page
|
|
3
|
+
* state such as `:checked`, `:hover` or `:focus` changes without any CDP
|
|
4
|
+
* event. Every daemon command that may change the page drops them, before
|
|
5
|
+
* and after it runs. Hooking the commands rather than the CDP methods they
|
|
6
|
+
* send keeps `dom inspect`'s own page scripts from clearing its answers, and
|
|
7
|
+
* listing the read-only commands makes a new command reset by default.
|
|
8
|
+
*/
|
|
9
|
+
import type { CDPConnection } from '../../connection/cdp.js';
|
|
10
|
+
import type { CommandName } from '../../ipc/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Commands that leave the page as it is: they read it, or only the telemetry.
|
|
13
|
+
* Any command not listed (new ones included) resets by default.
|
|
14
|
+
*/
|
|
15
|
+
export declare const KEEPS_MATCHED_STYLES: ReadonlySet<CommandName>;
|
|
16
|
+
/**
|
|
17
|
+
* Run a command, dropping the kept matched rules before and after it unless
|
|
18
|
+
* it leaves the page as it is.
|
|
19
|
+
*
|
|
20
|
+
* @param cdp - CDP connection
|
|
21
|
+
* @param name - Command name
|
|
22
|
+
* @param run - The command
|
|
23
|
+
* @returns Its result
|
|
24
|
+
*/
|
|
25
|
+
export declare function withMatchedStylesReset<T>(cdp: CDPConnection, name: CommandName, run: () => Promise<T>): Promise<T>;
|
|
26
|
+
//# sourceMappingURL=matchedStylesReset.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dom inspect` keeps slow matched-rules answers for a few seconds, but page
|
|
3
|
+
* state such as `:checked`, `:hover` or `:focus` changes without any CDP
|
|
4
|
+
* event. Every daemon command that may change the page drops them, before
|
|
5
|
+
* and after it runs. Hooking the commands rather than the CDP methods they
|
|
6
|
+
* send keeps `dom inspect`'s own page scripts from clearing its answers, and
|
|
7
|
+
* listing the read-only commands makes a new command reset by default.
|
|
8
|
+
*/
|
|
9
|
+
import { resetMatchedStyles } from '../../runtime/dom/inspectRules.js';
|
|
10
|
+
/**
|
|
11
|
+
* Commands that leave the page as it is: they read it, or only the telemetry.
|
|
12
|
+
* Any command not listed (new ones included) resets by default.
|
|
13
|
+
*/
|
|
14
|
+
export const KEEPS_MATCHED_STYLES = new Set([
|
|
15
|
+
'session_peek',
|
|
16
|
+
'session_details',
|
|
17
|
+
'session_status',
|
|
18
|
+
'session_har_data',
|
|
19
|
+
'session_network_headers',
|
|
20
|
+
'dom_frames',
|
|
21
|
+
'dom_form_discover',
|
|
22
|
+
'dom_listeners',
|
|
23
|
+
'dom_layout',
|
|
24
|
+
'dom_audit',
|
|
25
|
+
'css_search',
|
|
26
|
+
'dom_inspect',
|
|
27
|
+
]);
|
|
28
|
+
/**
|
|
29
|
+
* Run a command, dropping the kept matched rules before and after it unless
|
|
30
|
+
* it leaves the page as it is.
|
|
31
|
+
*
|
|
32
|
+
* @param cdp - CDP connection
|
|
33
|
+
* @param name - Command name
|
|
34
|
+
* @param run - The command
|
|
35
|
+
* @returns Its result
|
|
36
|
+
*/
|
|
37
|
+
export function withMatchedStylesReset(cdp, name, run) {
|
|
38
|
+
if (KEEPS_MATCHED_STYLES.has(name))
|
|
39
|
+
return run();
|
|
40
|
+
const reset = () => resetMatchedStyles(cdp);
|
|
41
|
+
reset();
|
|
42
|
+
const result = run();
|
|
43
|
+
void result.then(reset, reset);
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=matchedStylesReset.js.map
|
|
@@ -137,6 +137,7 @@ export function createDefaultTelemetryPlugins() {
|
|
|
137
137
|
fetchAllBodies: config.includeAll ?? false,
|
|
138
138
|
getCurrentNavigationId: store.getCurrentNavigationId ?? undefined,
|
|
139
139
|
pendingRequests: store.pendingNetworkRequests,
|
|
140
|
+
evictions: store.networkEvictions,
|
|
140
141
|
...filterDefined({
|
|
141
142
|
maxBodySize: config.maxBodySize,
|
|
142
143
|
}),
|
|
@@ -5,11 +5,6 @@
|
|
|
5
5
|
import type { TelemetryStore } from './TelemetryStore.js';
|
|
6
6
|
import type { TriggeredRequest } from '../../ipc/protocol/domTypes.js';
|
|
7
7
|
import type { NetworkRequest } from '../../types.js';
|
|
8
|
-
/**
|
|
9
|
-
* Requests listed in a result (a click that loads a page triggers its whole
|
|
10
|
-
* load); notable ones ({@link isNotableRequest}) are kept before assets
|
|
11
|
-
*/
|
|
12
|
-
export declare const MAX_TRIGGERED_REQUESTS = 50;
|
|
13
8
|
/** Requests started since the watch began: the first ones, and how many more there were */
|
|
14
9
|
export interface CollectedRequests {
|
|
15
10
|
triggeredRequests: TriggeredRequest[];
|
|
@@ -2,15 +2,11 @@
|
|
|
2
2
|
* Network requests an interaction triggered, read from the session's network
|
|
3
3
|
* telemetry (no CDP listeners of its own).
|
|
4
4
|
*/
|
|
5
|
+
import { MAX_TRIGGERED_REQUESTS } from '../../constants.js';
|
|
5
6
|
import { isNotableRequest } from '../../telemetry/requestKinds.js';
|
|
6
7
|
import { failureReason, getRequestState } from '../../telemetry/requestState.js';
|
|
7
8
|
/** URLs that never reach the network (inline data, in-page objects) */
|
|
8
9
|
const LOCAL_URL_PATTERN = /^(data|blob):/i;
|
|
9
|
-
/**
|
|
10
|
-
* Requests listed in a result (a click that loads a page triggers its whole
|
|
11
|
-
* load); notable ones ({@link isNotableRequest}) are kept before assets
|
|
12
|
-
*/
|
|
13
|
-
export const MAX_TRIGGERED_REQUESTS = 50;
|
|
14
10
|
/**
|
|
15
11
|
* Start attributing requests to an interaction.
|
|
16
12
|
*
|
|
@@ -28,11 +24,12 @@ export function watchTriggeredRequests(store) {
|
|
|
28
24
|
if (!store.activeTelemetry.includes('network'))
|
|
29
25
|
return () => undefined;
|
|
30
26
|
const startedAt = Date.now();
|
|
31
|
-
const firstFinished = store
|
|
27
|
+
const firstFinished = requestsFinished(store);
|
|
32
28
|
const firstWebSocket = store.websocketConnections.length;
|
|
33
29
|
return () => {
|
|
30
|
+
const firstKept = Math.max(0, firstFinished - store.networkEvictions.requestsDropped);
|
|
34
31
|
const started = [
|
|
35
|
-
...store.networkRequests.slice(
|
|
32
|
+
...store.networkRequests.slice(firstKept).map((request) => ({ request })),
|
|
36
33
|
...[...store.pendingNetworkRequests.values()].map((pending) => ({
|
|
37
34
|
request: pending.request,
|
|
38
35
|
inFlight: true,
|
|
@@ -52,6 +49,15 @@ export function watchTriggeredRequests(store) {
|
|
|
52
49
|
};
|
|
53
50
|
};
|
|
54
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Requests the session has finished, dropped ones included.
|
|
54
|
+
*
|
|
55
|
+
* @param store - Session store
|
|
56
|
+
* @returns Count that only grows
|
|
57
|
+
*/
|
|
58
|
+
function requestsFinished(store) {
|
|
59
|
+
return store.networkEvictions.requestsDropped + store.networkRequests.length;
|
|
60
|
+
}
|
|
55
61
|
/**
|
|
56
62
|
* At most `limit` requests, notable ones first (pages, API calls, sockets,
|
|
57
63
|
* failures), then assets, still in start order.
|