Skip to content

Conversation

@karlseguin
Copy link
Contributor

@krichprollsch
Copy link
Member

krichprollsch commented Aug 19, 2025

I'm adding a test with chromedp. I try to fillfull an XHR response for the reviews, but it doesn't work for now.
The script blocks and timeout. I'm trying to understand where the issue is, it could be due to my chromedp usage.

$ cd chromedp
$ go run  ri/main.go -verbose http://127.0.0.1:1234/campfire-commerce/
[...]
INTERCEPT-4 http://127.0.0.1:1234/campfire-commerce/json/reviews.json
2025/08/19 14:58:22 -> {"id":19,"sessionId":"SID-1","method":"Fetch.fulfillRequest","params":{"requestId":"INTERCEPT-4","responseCode":200,"body":"[\"alter review\"]"}}
2025/08/19 14:58:22 -> {"id":20,"sessionId":"SID-1","method":"DOM.getDocument","params":{"pierce":false}}
2025/08/19 14:58:22 <- {"id":18,"result":{},"sessionId":"SID-1"}
2025/08/19 14:58:22 <- {"id":19,"code":-31998,"message":"InvalidCharacter"}
get reviews: context canceled
exit status 1
[...]
DEBUG http : request start . . . . . . . . . . . . . . . . .  [+403.601s]
      method = GET
      url = http://127.0.0.1:1234/campfire-commerce/json/product.json
      source = xhr

* Reusing existing http: connection with host 127.0.0.1
> GET /campfire-commerce/json/product.json HTTP/1.1
Host: 127.0.0.1:1234
Accept: */*
Accept-Encoding: deflate, gzip
Cookie: left=right
User-Agent: Lightpanda/1.0

* Request completely sent off
DEBUG cdp : request intercept . . . . . . . . . . . . . . . . [+403.601s]
      state = fulfilled
      id = 4
      url = http://127.0.0.1:1234/campfire-commerce/json/reviews.json
      status = 200
      body = true

INFO  app : client disconnected . . . . . . . . . . . . . . . [+403.601s]

DEBUG script_event : dispatch event . . . . . . . . . . . . . [+403.601s]
      type = readystatechange
      source = xhr
      method = GET
      url = http://127.0.0.1:1234/campfire-commerce/json/product.json

DEBUG script_event : dispatch progress event . . . . . . . .  [+403.601s]
      type = abort
      source = xhr
      method = GET
      url = http://127.0.0.1:1234/campfire-commerce/json/product.json

DEBUG script_event : dispatch progress event . . . . . . . .  [+403.601s]
      type = loadend
      source = xhr
      method = GET
      url = http://127.0.0.1:1234/campfire-commerce/json/product.json

DEBUG http : error . . . . . . . . . . . . . . . . . . . . .  [+403.601s]
      url = http://127.0.0.1:1234/campfire-commerce/json/product.json
      err = Abort
      source = xhr.OnErr

* closing connection #4
DEBUG browser : remove page . . . . . . . . . . . . . . . . . [+403.602s]

DEBUG app : accepting connection . . . . . . . . . . . . . .  [+403.605s]

@krichprollsch
Copy link
Member

ok this issue was I didn't base64 encode my body.
No it's working but it's flaky, sometimes it work, sometimes it doesn't get the text for the node...
ofc w/ chrome is works all the time...
Maybe it's due to event or message order. not sure.
I'm trying to isolate the diff.

@krichprollsch
Copy link
Member

ok, adding a PopulateWait fixed the issue. the chromedp test works well now.

@karlseguin
Copy link
Contributor Author

ok, adding a PopulateWait fixed the issue. the chromedp test works well now.

I think this is the same issue I ran into lightpanda-io/browser#946 (comment)

Chrome does wait, but I'm still not clear on what. Nevertheless, it seems more correct to have the script probe/query the document for whatever state it's after.

@karlseguin karlseguin merged commit f1b8ff3 into main Aug 20, 2025
@karlseguin karlseguin deleted the request_interception branch August 20, 2025 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants