k6 icon indicating copy to clipboard operation
k6 copied to clipboard

browser: add `page.on('requestfailed')` event handler

Open pkalsi97 opened this issue 2 weeks ago • 0 comments

What?

This PR Adds the page.on('requestfailed') event handler to the k6 browser module, following the Playwright API.

This event fires when a network request fails to reach the server: in the following cases : DNS errors, connection refused, timeouts, etc. It does not fire for HTTP 4xx/5xx responses, which are successful network requests.

Note: I have closely followed the implementation of page.on('request') and page.on('response') events.

Why?

Reasons mentioned in the issue #4299 description.

Checklist

  • [x] I have performed a self-review of my code.
  • [x] I have commented on my code, particularly in hard-to-understand areas.
  • [x] I have added tests for my changes.
  • [x] I have run linter and tests locally (make check) and all pass.

Checklist: Documentation (only for k6 maintainers and if relevant)

Please do not merge this PR until the following items are filled out.

  • [ ] I have added the correct milestone and labels to the PR.
  • [ ] I have updated the release notes: link
  • [ ] I have updated or added an issue to the k6-documentation: grafana/k6-docs#NUMBER if applicable
  • [ ] I have updated or added an issue to the TypeScript definitions: grafana/k6-DefinitelyTyped#NUMBER if applicable

Related PR(s)/Issue(s)

Closes: #4299 Parent: #4232

pkalsi97 avatar Dec 11 '25 08:12 pkalsi97