-
Notifications
You must be signed in to change notification settings - Fork 163
Tracing: Fix tracing headers causing CORS issue #640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b156230
to
b457858
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
await page.setExtraHTTPHeaders(options.headers as any); | ||
if (options.headers && options.headers['Accept-Language']) { | ||
const headers = { 'Accept-Language': options.headers['Accept-Language'] }; | ||
this.log.debug(`Setting extra HTTP headers for page`, 'headers', headers); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to keep these debug logs for future troubleshooting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't add this one but yes I think it can be interesting for troubleshooting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses a CORS issue by switching the approach from removing headers on certain requests to only adding tracing headers when appropriate. The main changes include passing header options to page listeners in reusable, clustered, and browser modules, updating the logic for adding tracing headers, and refining the extra HTTP headers setup.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/browser/reusable.ts | Updated calls to addPageListeners to pass the headers from options. |
src/browser/clustered.ts | Similar updates to pass header options to addPageListeners. |
src/browser/browser.ts | Modified addPageListeners and tracing header logic to only add headers when conditions apply, and refined the HTTP header setup. |
Comments suppressed due to low confidence (1)
src/browser/browser.ts:630
- Update the error message in the catch block to reflect that the code is now adding tracing headers rather than removing them, e.g., 'Failed to add tracing headers'.
this.log.debug('Failed to remove tracing header', 'url', url, 'referer', referer, 'error', error.message);
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Ezequiel Victorero <ezequiel.victorero@grafana.com>
It seems that
page.on('request', ...)
isn't triggered on EVERY request so adding the headers for every request and removing them here wasn't working for some requests.This is achieving the same result, the other way around, only adding headers for requests we are sure we should add them.