Increase default execution timeout from 5s to 10s
This commit is contained in:
@@ -1065,7 +1065,7 @@ export async function startPlayWriterCDPRelayServer({ port = 19988, host = '127.
|
|||||||
app.post('/cli/execute', async (c) => {
|
app.post('/cli/execute', async (c) => {
|
||||||
try {
|
try {
|
||||||
const body = await c.req.json() as { sessionId: string; code: string; timeout?: number; cwd?: string }
|
const body = await c.req.json() as { sessionId: string; code: string; timeout?: number; cwd?: string }
|
||||||
const { sessionId, code, timeout = 5000, cwd } = body
|
const { sessionId, code, timeout = 10000, cwd } = body
|
||||||
|
|
||||||
if (!sessionId || !code) {
|
if (!sessionId || !code) {
|
||||||
return c.json({ error: 'sessionId and code are required' }, 400)
|
return c.json({ error: 'sessionId and code are required' }, 400)
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ cli
|
|||||||
.option('--token <token>', 'Authentication token (or use PLAYWRITER_TOKEN env var)')
|
.option('--token <token>', 'Authentication token (or use PLAYWRITER_TOKEN env var)')
|
||||||
.option('-s, --session <name>', 'Session ID (required for -e, get one with `playwriter session new`)')
|
.option('-s, --session <name>', 'Session ID (required for -e, get one with `playwriter session new`)')
|
||||||
.option('-e, --eval <code>', 'Execute JavaScript code and exit, read https://playwriter.dev/SKILL.md for usage')
|
.option('-e, --eval <code>', 'Execute JavaScript code and exit, read https://playwriter.dev/SKILL.md for usage')
|
||||||
.option('--timeout <ms>', 'Execution timeout in milliseconds', { default: 5000 })
|
.option('--timeout <ms>', 'Execution timeout in milliseconds', { default: 10000 })
|
||||||
.action(async (options: { host?: string; token?: string; eval?: string; timeout?: number; session?: string }) => {
|
.action(async (options: { host?: string; token?: string; eval?: string; timeout?: number; session?: string }) => {
|
||||||
// If -e flag is provided, execute code via relay server
|
// If -e flag is provided, execute code via relay server
|
||||||
if (options.eval) {
|
if (options.eval) {
|
||||||
await executeCode({
|
await executeCode({
|
||||||
code: options.eval,
|
code: options.eval,
|
||||||
timeout: options.timeout || 5000,
|
timeout: options.timeout || 10000,
|
||||||
sessionId: options.session,
|
sessionId: options.session,
|
||||||
host: options.host,
|
host: options.host,
|
||||||
token: options.token,
|
token: options.token,
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ export class PlaywrightExecutor {
|
|||||||
return { browser, page }
|
return { browser, page }
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getCurrentPage(timeout = 5000): Promise<Page> {
|
private async getCurrentPage(timeout = 10000): Promise<Page> {
|
||||||
if (this.page && !this.page.isClosed()) {
|
if (this.page && !this.page.isClosed()) {
|
||||||
return this.page
|
return this.page
|
||||||
}
|
}
|
||||||
@@ -365,7 +365,7 @@ export class PlaywrightExecutor {
|
|||||||
return { page, context }
|
return { page, context }
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(code: string, timeout = 5000): Promise<ExecuteResult> {
|
async execute(code: string, timeout = 10000): Promise<ExecuteResult> {
|
||||||
const consoleLogs: Array<{ method: string; args: any[] }> = []
|
const consoleLogs: Array<{ method: string; args: any[] }> = []
|
||||||
|
|
||||||
const formatConsoleLogs = (logs: Array<{ method: string; args: any[] }>, prefix = 'Console output') => {
|
const formatConsoleLogs = (logs: Array<{ method: string; args: any[] }>, prefix = 'Console output') => {
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ server.tool(
|
|||||||
.describe(
|
.describe(
|
||||||
'js playwright code, has {page, state, context} in scope. Should be one line, using ; to execute multiple statements. you MUST call execute multiple times instead of writing complex scripts in a single tool call.',
|
'js playwright code, has {page, state, context} in scope. Should be one line, using ; to execute multiple statements. you MUST call execute multiple times instead of writing complex scripts in a single tool call.',
|
||||||
),
|
),
|
||||||
timeout: z.number().default(5000).describe('Timeout in milliseconds for code execution (default: 5000ms)'),
|
timeout: z.number().default(10000).describe('Timeout in milliseconds for code execution (default: 10000ms)'),
|
||||||
},
|
},
|
||||||
async ({ code, timeout }) => {
|
async ({ code, timeout }) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user