Skip to content

cdp: complete Network events and include worker requests#3037

Merged
karlseguin merged 3 commits into
lightpanda-io:mainfrom
Ppsoft1991:fix/cdp-network-events
Jul 25, 2026
Merged

cdp: complete Network events and include worker requests#3037
karlseguin merged 3 commits into
lightpanda-io:mainfrom
Ppsoft1991:fix/cdp-network-events

Conversation

@Ppsoft1991

Copy link
Copy Markdown
Contributor

Summary

  • add required CDP fields to Network events and their request, response, and timing payloads
  • emit Network.requestWillBeSent for WorkerGlobalScope requests that are not present in the document frame tree
  • add a regression fixture covering both the Worker script and a Fetch issued from inside the Worker

Problem

Strict CDP clients discard Lightpanda Network messages when protocol-required fields are absent. Worker requests had a separate issue: their WorkerGlobalScope frame IDs do not resolve through the document frame tree, so requestWillBeSent returned early while later response events were still emitted.

Testing

  • targeted CDP Network tests: 9/9 passed
  • full Lightpanda test suite with Zig 0.16.0: 1062/1062 passed
  • formatting checked for every tracked Zig source
  • external CDP probe captured the document, an eval-issued Fetch, the Worker script, and a Fetch issued inside the Worker

Add required timestamp, type, request, response, and timing fields so strict CDP clients can deserialize emitted events.
try jws.write("High");
}

{

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is accurate. Unless you have a strong need for this right now, I'd rather leave it out until we can generate a correct value

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that hardcoding strict-origin-when-cross-origin is inaccurate. However, chromiumoxide treats referrerPolicy as required and drops the entire Network.requestWillBeSent event when it is missing. Could we expose the policy Lightpanda actually applies instead of omitting the field?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I set it to unsafe-url.

Comment thread src/cdp/domains/network.zig Outdated
Comment thread src/cdp/domains/network.zig Outdated
Keep worker requests visible on the page CDP session when their WorkerGlobalScope frame id is absent from the document frame tree. Add a regression fixture covering the worker script and a fetch from inside the worker.
@karlseguin
karlseguin force-pushed the fix/cdp-network-events branch from 878f6ac to e3ec937 Compare July 25, 2026 00:01
@karlseguin

Copy link
Copy Markdown
Collaborator

I just rebased, didn't touch anything else.

Give accurate connectionId, connectionReused, initialPriority and securityState
values.

Always set `referrerPolicy` to `unsafe-url` as the most honest answer (we should
implement proper referrer policy!).

For workers, track the underlying frame_id so that it can be used for the
`documentURL` field.
@karlseguin

Copy link
Copy Markdown
Collaborator

@Ppsoft1991 are you able to test the last version of this PR on your use case?

@Ppsoft1991

Copy link
Copy Markdown
Contributor Author

@Ppsoft1991 are you able to test the last version of this PR on your use case?

I tested the latest version at 5acfd38:
SSO navigation completed successfully, including cross-origin redirects.
Network events for Documents, Scripts, XHR, eval-triggered Fetch, Worker scripts, and Worker-triggered Fetch were captured successfully.
The strict CDP client deserialized all Network events without missing-field errors.
Network tests passed 10/10; the full test suite passed 1074/1074.
The latest version works as expected. Thank you.

@karlseguin
karlseguin merged commit f72cba8 into lightpanda-io:main Jul 25, 2026
25 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants