fix stagehand timeout - send attachedToTarget after attachToTarget returns (0.0.16)
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
# Changelog
|
||||
|
||||
## 0.0.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- **Fixed Stagehand timeout**: Send `Target.attachedToTarget` event after `Target.attachToTarget` returns
|
||||
- Stagehand creates sessions from `attachToTarget` response, then expects `attachedToTarget` event to create Page
|
||||
- Previously events were only sent from `setAutoAttach` which arrived before sessions were created
|
||||
|
||||
## 0.0.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "playwriter",
|
||||
"description": "",
|
||||
"version": "0.0.15",
|
||||
"version": "0.0.16",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
||||
@@ -351,7 +351,7 @@ export async function startPlayWriterCDPRelayServer({ port = 19988, host = '127.
|
||||
}
|
||||
}
|
||||
|
||||
if (method === 'Target.setDiscoverTargets' && (params)?.discover) {
|
||||
if (method === 'Target.setDiscoverTargets' && (params as any)?.discover) {
|
||||
for (const target of connectedTargets.values()) {
|
||||
const targetCreatedPayload = {
|
||||
method: 'Target.targetCreated',
|
||||
@@ -371,6 +371,30 @@ export async function startPlayWriterCDPRelayServer({ port = 19988, host = '127.
|
||||
}
|
||||
}
|
||||
|
||||
if (method === 'Target.attachToTarget' && result?.sessionId) {
|
||||
const targetId = params?.targetId
|
||||
const target = Array.from(connectedTargets.values()).find(t => t.targetId === targetId)
|
||||
if (target) {
|
||||
const attachedPayload = {
|
||||
method: 'Target.attachedToTarget',
|
||||
params: {
|
||||
sessionId: result.sessionId,
|
||||
targetInfo: {
|
||||
...target.targetInfo,
|
||||
attached: true
|
||||
},
|
||||
waitingForDebugger: false
|
||||
}
|
||||
} satisfies CDPEventFor<'Target.attachedToTarget'>
|
||||
logger?.log(chalk.magenta('[Server] Target.attachedToTarget (from attachToTarget) payload:'), JSON.stringify(attachedPayload))
|
||||
sendToPlaywright({
|
||||
message: attachedPayload,
|
||||
clientId,
|
||||
source: 'server'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
sendToPlaywright({
|
||||
message: { id, sessionId, result },
|
||||
clientId
|
||||
|
||||
@@ -610,8 +610,8 @@ describe('MCP Server Tests', () => {
|
||||
expect(results).toMatchInlineSnapshot(`
|
||||
[
|
||||
{
|
||||
"title": "🎄 Twelve Days of Shell 🎄",
|
||||
"url": "https://12days.cmdchallenge.com/",
|
||||
"title": "",
|
||||
"url": "about:blank",
|
||||
},
|
||||
{
|
||||
"title": "Example Domain",
|
||||
@@ -696,8 +696,8 @@ describe('MCP Server Tests', () => {
|
||||
expect(results).toMatchInlineSnapshot(`
|
||||
[
|
||||
{
|
||||
"title": "🎄 Twelve Days of Shell 🎄",
|
||||
"url": "https://12days.cmdchallenge.com/",
|
||||
"title": "",
|
||||
"url": "about:blank",
|
||||
},
|
||||
{
|
||||
"title": "Example Domain",
|
||||
|
||||
Reference in New Issue
Block a user