Skip to content

Fix issue #243, where multiple requests not handled correctly#244

Open
sufian-cf wants to merge 13 commits intomainfrom
sufian/fix-har-url-matching
Open

Fix issue #243, where multiple requests not handled correctly#244
sufian-cf wants to merge 13 commits intomainfrom
sufian/fix-har-url-matching

Conversation

@sufian-cf
Copy link
Copy Markdown
Contributor

@sufian-cf sufian-cf commented Apr 16, 2026

This change fixes issue #243 by adding a new x-telescope-id header, 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).

…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.
Comment thread src/testRunner.ts Outdated
Comment thread src/types.ts
export interface RequestData {
url: string;
timing: RequestTiming;
rawTimings?: boolean;
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.

This rawTimings field was always false and never used, so I've removed it.

Comment thread src/types.ts
* Request data collected during test
*/
export interface RequestData {
url: string;
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.

Similarly, we don't need this anymore, since we can match on telescopeId exactly

Comment thread src/testRunner.ts
});

page.on('requestfinished', data => {
const telescopeId = data.headers()[TELESCOPE_ID_HEADER];
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.

When we measure performance information, we can now associate the timing information with the exact request id.

@sufian-cf sufian-cf marked this pull request as ready for review April 16, 2026 16:39
@sufian-cf sufian-cf requested a review from a team April 16, 2026 16:39
mjkozicki
mjkozicki previously approved these changes Apr 16, 2026
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.

2 participants