Skip to content

Example do not work with chromedp #390

@sganon

Description

@sganon

Description

When attempting to implement the example given in the README via chromedp a popular CDP implementation in Go, the program returns an error context canceled.

After investigation this comes after the page navigate. A msg is received which apparently is malformed, as it returns this error:
parse error: syntax error near offset 274 of 'BROWSERSES...'. When this happens chromedp break off its main loop, causing a disconnection of the browser and rendering subsequent actions impossible to make.

Note: To debug this message from chromedp you'll need to modify this line

Logs

When adding log to chromedp when receiving message (starting with msg.ID) and executing commands (TARGET EXECUTE) I Get this result:

msg.ID: 0, msg.Method: Target.targetCreated, msg.SessionID:
msg.ID: 0, msg.Method: Target.attachedToTarget, msg.SessionID:
msg.ID: 1, msg.Method: , msg.SessionID:
msg.ID: 0, msg.Method: Target.attachedToTarget, msg.SessionID:
msg.ID: 2, msg.Method: , msg.SessionID:
TARGET EXECUTE Runtime.enable <nil>
msg.ID: 0, msg.Method: Runtime.executionContextCreated, msg.SessionID: BROWSERSESSIONID597D9875C664CAC0
msg.ID: 3, msg.Method: , msg.SessionID: BROWSERSESSIONID597D9875C664CAC0
msg.ID: 3, msg.Method: , msg.SessionID: BROWSERSESSIONID597D9875C664CAC0
TARGET EXECUTE Runtime.evaluate &{self  false false 0 false false false false false 0 false false false  <nil>}
msg.ID: 4, msg.Method: , msg.SessionID: BROWSERSESSIONID597D9875C664CAC0
msg.ID: 4, msg.Method: , msg.SessionID: BROWSERSESSIONID597D9875C664CAC0
TARGET EXECUTE Log.enable <nil>
msg.ID: 5, msg.Method: , msg.SessionID: BROWSERSESSIONID597D9875C664CAC0
TARGET EXECUTE Network.enable &{0 0 0}
msg.ID: 6, msg.Method: , msg.SessionID: BROWSERSESSIONID597D9875C664CAC0
TARGET EXECUTE Inspector.enable <nil>
msg.ID: 7, msg.Method: , msg.SessionID: BROWSERSESSIONID597D9875C664CAC0
TARGET EXECUTE Page.enable <nil>
msg.ID: 8, msg.Method: , msg.SessionID: BROWSERSESSIONID597D9875C664CAC0
TARGET EXECUTE DOM.enable &{}
msg.ID: 9, msg.Method: , msg.SessionID: BROWSERSESSIONID597D9875C664CAC0
TARGET EXECUTE CSS.enable <nil>
msg.ID: 10, msg.Method: , msg.SessionID: BROWSERSESSIONID597D9875C664CAC0
TARGET EXECUTE Target.setDiscoverTargets &{true []}
msg.ID: 11, msg.Method: , msg.SessionID: BROWSERSESSIONID597D9875C664CAC0
TARGET EXECUTE Target.setAutoAttach &{true false true []}
msg.ID: 12, msg.Method: , msg.SessionID: BROWSERSESSIONID597D9875C664CAC0
TARGET EXECUTE Page.setLifecycleEventsEnabled &{true}
msg.ID: 13, msg.Method: , msg.SessionID: BROWSERSESSIONID597D9875C664CAC0
TARGET EXECUTE Page.navigate &{http://localhost:8080/    }
msg.ID: 0, msg.Method: Page.frameStartedLoading, msg.SessionID: BROWSERSESSIONID597D9875C664CAC0
msg.ID: 0, msg.Method: Page.lifecycleEvent, msg.SessionID: BROWSERSESSIONID597D9875C664CAC0
msg.ID: 14, msg.Method: , msg.SessionID: BROWSERSESSIONID597D9875C664CAC0
msg.ID: 0, msg.Method: Runtime.executionContextsCleared, msg.SessionID: BROWSERSESSIONID597D9875C664CAC0

If you add log to the Read method you can actually print the message that cause the issue which is:

{"method":"Runtime.executionContextCreated","params":{"context":{"id":2,"origin":"http://localhost:8080","name":"","uniqueId":"211316841551650330.9136120204379184874","auxData":{"isDefault":true,"type":"default","frameId":"TARGETID460A8F29706A2ADF14316298"}}},"sessionId":""BROWSERSESSIONID597D9875C664CAC"}

Which has a extra " before the sessionID

Steps to reproduce

Here is a gist for the example implementation, using a dev build of browser on this commit: a74c9e8

Metadata

Metadata

Assignees

Labels

CDPChrome Debug ProtocolbugSomething isn't workingchromedp

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions