Ignore errors and UI interactions in fetch tool

This commit is contained in:
Dmitriy Vasyura
2025-12-04 11:21:56 -08:00
parent a44beb9c39
commit 8450fc3285
@@ -72,6 +72,13 @@ export class WebPageLoader extends Disposable {
.once('did-fail-load', this.onFailLoad.bind(this))
.once('will-navigate', this.onRedirect.bind(this))
.once('will-redirect', this.onRedirect.bind(this));
// Disable any UI interactions that could interfere with content loading.
this._window.webContents
.on('login', (event) => event.preventDefault())
.on('select-client-certificate', (event) => event.preventDefault())
.on('certificate-error', (event) => event.preventDefault());
}
private trace(message: string) {
@@ -164,7 +171,12 @@ export class WebPageLoader extends Disposable {
}
this.trace(`Received 'did-fail-load' event, code: ${statusCode}, error: '${error}'`);
void this._queue.queue(() => this.extractContent({ status: 'error', statusCode, error }));
if (statusCode === -3) {
this.trace(`Ignoring ERR_ABORTED (-3) as it may be caused by CSP or other measures`);
void this._queue.queue(() => this.extractContent());
} else {
void this._queue.queue(() => this.extractContent({ status: 'error', statusCode, error }));
}
}
/**