Fix issue #243, where multiple requests not handled correctly#244
Open
Fix issue #243, where multiple requests not handled correctly#244
Conversation
…RL HAR entries When multiple requests share the same URL (e.g., a CSS file loaded via <link> and fetched again via JS), mergeEntries only applies timing data to the first matching entry. The remaining entries are left without custom timing fields (_dns_start, _connect_start, etc.).
Inject a unique x-telescope-id request header via route.fallback() so each request gets a stable identifier that appears in both the requestfinished event and the Playwright-generated HAR. mergeEntries now matches on this header instead of URL, correctly correlating timing data even when multiple requests share the same URL. Also removes the unused rawTimings field from RequestData, which was never set anywhere in the codebase.
The package-lock.json was not updated after msw was moved to be a devDependency (in 690199f).
Build a telescopeId → index map upfront instead of scanning all HAR entry headers on every request.
sufian-cf
commented
Apr 16, 2026
sufian-cf
commented
Apr 16, 2026
| export interface RequestData { | ||
| url: string; | ||
| timing: RequestTiming; | ||
| rawTimings?: boolean; |
Contributor
Author
There was a problem hiding this comment.
This rawTimings field was always false and never used, so I've removed it.
sufian-cf
commented
Apr 16, 2026
| * Request data collected during test | ||
| */ | ||
| export interface RequestData { | ||
| url: string; |
Contributor
Author
There was a problem hiding this comment.
Similarly, we don't need this anymore, since we can match on telescopeId exactly
sufian-cf
commented
Apr 16, 2026
| }); | ||
|
|
||
| page.on('requestfinished', data => { | ||
| const telescopeId = data.headers()[TELESCOPE_ID_HEADER]; |
Contributor
Author
There was a problem hiding this comment.
When we measure performance information, we can now associate the timing information with the exact request id.
mjkozicki
previously approved these changes
Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change fixes issue #243 by adding a new
x-telescope-idheader, containing a unique uuid, to each request made by telescope.The performance data we're capturing needs to be associated with the HAR, but there isn't a good way to do that without having some sort of unique identifier. We previously were using URL, but that doesn't work if multiple requests are made to the same URL in a telescope test run.
So by adding a header, we can cross-reference the data correctly, and have an added benefit for debugging server-side, so users can identify which requests went sideways via this header (it is present in the generated HAR, and will be sent to servers as
x-telescope-id).Note: this also adds package-lock.json changes which should have been added in commit 690199f (msw moved to devDependencies).