better logs for maps and sets
This commit is contained in:
@@ -53,6 +53,20 @@ function safeSerialize(arg: any): string {
|
|||||||
if (typeof value === 'object' && value !== null) {
|
if (typeof value === 'object' && value !== null) {
|
||||||
if (seen.has(value)) return '[Circular]';
|
if (seen.has(value)) return '[Circular]';
|
||||||
seen.add(value);
|
seen.add(value);
|
||||||
|
|
||||||
|
if (value instanceof Map) {
|
||||||
|
return {
|
||||||
|
dataType: 'Map',
|
||||||
|
value: Array.from(value.entries())
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value instanceof Set) {
|
||||||
|
return {
|
||||||
|
dataType: 'Set',
|
||||||
|
value: Array.from(value.values())
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
});
|
});
|
||||||
@@ -394,7 +408,7 @@ export class RelayConnection {
|
|||||||
//
|
//
|
||||||
// To fix this, we intercept 'Runtime.enable' and force a reset:
|
// To fix this, we intercept 'Runtime.enable' and force a reset:
|
||||||
// 1. We send 'Runtime.disable'. This clears Chrome's internal Runtime state for this session.
|
// 1. We send 'Runtime.disable'. This clears Chrome's internal Runtime state for this session.
|
||||||
// 2. We wait a brief moment (50ms) to ensure the disable command propagates.
|
// 2. We wait a brief moment (100ms) to ensure the disable command propagates.
|
||||||
// 3. Then we allow the original 'Runtime.enable' command to proceed.
|
// 3. Then we allow the original 'Runtime.enable' command to proceed.
|
||||||
//
|
//
|
||||||
// This sequence forces Chrome to treat the enablement as a fresh start, causing it to
|
// This sequence forces Chrome to treat the enablement as a fresh start, causing it to
|
||||||
@@ -404,7 +418,7 @@ export class RelayConnection {
|
|||||||
logger.debug('Runtime.enable called, disabling first to force context refresh for tab:', targetTab.debuggee.tabId);
|
logger.debug('Runtime.enable called, disabling first to force context refresh for tab:', targetTab.debuggee.tabId);
|
||||||
try {
|
try {
|
||||||
await chrome.debugger.sendCommand(debuggerSession, 'Runtime.disable');
|
await chrome.debugger.sendCommand(debuggerSession, 'Runtime.disable');
|
||||||
await new Promise(resolve => setTimeout(resolve, 50));
|
await new Promise(resolve => setTimeout(resolve, 100));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.debug('Error disabling Runtime (ignoring):', e);
|
logger.debug('Error disabling Runtime (ignoring):', e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,14 @@ the chrome window can have more than one page. you can see other pages with `con
|
|||||||
|
|
||||||
you can control the browser in collaboration with the user. the user can help you get unstuck from captchas or difficult to find elements or reproducing a bug
|
you can control the browser in collaboration with the user. the user can help you get unstuck from captchas or difficult to find elements or reproducing a bug
|
||||||
|
|
||||||
|
## capabilities
|
||||||
|
|
||||||
|
examples of things playwriter MCP can do:
|
||||||
|
- monitor logs for a page while the user reproduces a but to let you understand what is causing a bug
|
||||||
|
- monitor logs while also controlling the page, then read collected logs and debug an issue
|
||||||
|
- monitor xhr network requests while scrolling an infinite scroll page to extract data from a website
|
||||||
|
- get accessibility snapshot to see clickable elements on the page, then click or interact with them to automate a task like ordering pizza
|
||||||
|
|
||||||
## finding the page to execute code in
|
## finding the page to execute code in
|
||||||
|
|
||||||
if you plan to control a specific page for an url you can store it in `state` so you can reuse it later on:
|
if you plan to control a specific page for an url you can store it in `state` so you can reuse it later on:
|
||||||
|
|||||||
Reference in New Issue
Block a user