Skip to content

Commit

Permalink
fix(agent): support callbacks in chrome internal urls
Browse files Browse the repository at this point in the history
  • Loading branch information
soundofspace committed Feb 5, 2025
1 parent 6b46e57 commit 044f3c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions agent/main/lib/Console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,16 @@ export class Console extends TypedEventEmitter<IConsoleEvents> {
function injectedScript(): void {
const clientId = Math.random().toString().slice(2, 12);

const url = `http://hero.localhost/?secretKey=${this.secretKey}&action=registerConsoleClientId&clientId=${clientId}`;

// This will signal to network manager we are trying to make websocket connection
// This is needed later to map clientId to frameId

const scheme = location.href.startsWith('chrome://') ? 'data' : 'http'
const url = `${scheme}://hero.localhost/?secretKey=${this.secretKey}&action=registerConsoleClientId&clientId=${clientId}`;
if (scheme === 'data') {
// eslint-disable-next-line no-console
console.info('Using fetch with data:// scheme, http:// not supported inside chrome:// urls, ignore fetch errors including data:// scheme')
}

void fetch(url, { mode: 'no-cors' }).catch(() => undefined);

// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
2 changes: 1 addition & 1 deletion agent/main/lib/NetworkManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default class NetworkManager extends TypedEventEmitter<IBrowserNetworkEve
if (maxResourceBufferSize > 0) this.isChromeRetainingResources = true;

const patternsToIntercepts: Fetch.RequestPattern[] = [
{ urlPattern: 'http://hero.localhost/*' },
{ urlPattern: '://hero.localhost/*' },
];
if (this.proxyConnectionOptions?.password) {
// Pattern needs to match website url (not proxy url), so wildcard is only option we really have here
Expand Down

0 comments on commit 044f3c7

Please sign in to comment.