Skip to content

loadUrl error "ERR_ABORTED (-3) error" can't be catched #27574

Closed

Description

@benoittgt

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    • v10.1.1
  • Operating System:
    • v10.15.7

Expected Behavior

Uncaught (in promise) Error: ERR_ABORTED (-3) raised by

// the webcontents has started another unrelated navigation in the
// main frame (probably from the app calling `loadURL` again); reject
// the promise
// We should only consider the request aborted if the "navigation" is
// actually navigating and not simply transitioning URL state in the
// current context. E.g. pushState and `location.hash` changes are
// considered navigation events but are triggered with isSameDocument.
// We can ignore these to allow virtual routing on page load as long
// as the routing does not leave the document
return rejectAndCleanup(-3, 'ERR_ABORTED', url);
can be catched by win.webContents.on('did-fail-load', () => {})

Actual Behavior

Error thrown by

// the webcontents has started another unrelated navigation in the
// main frame (probably from the app calling `loadURL` again); reject
// the promise
// We should only consider the request aborted if the "navigation" is
// actually navigating and not simply transitioning URL state in the
// current context. E.g. pushState and `location.hash` changes are
// considered navigation events but are triggered with isSameDocument.
// We can ignore these to allow virtual routing on page load as long
// as the routing does not leave the document
return rejectAndCleanup(-3, 'ERR_ABORTED', url);
cannot be catched in context of a redirect.

  const { remote } = require('electron');
  const win = new remote.BrowserWindow({
    width: 800,
    height: 600,
    show: false,
    webPreferences: {
      partition: LOGIN_PARTITION,
      nodeIntegration: false,
    },
  });
  win.webContents.on('did-finish-load', () => {
    console.log('finish-load'); // triggered twice
  });
  win.webContents.on('did-fail-load', () => {
    console.log('fail-load'); // never triggered
  });
  try {
    win.loadURL(urlThatContainsAutoRedirect);
  } catch (error) {
    console.log('catch loadUrl'); // never triggered
  }
  win.show();

Screenshot 2021-02-01 at 18 06 01

Reproduce

Sadly the flow I use is based on Auth0 login page, that automatically redirect to a page behind authentication if we have the same partition. I cannot provide a way to reproduce.

Related:

Activity

  1. changed the title [-]loadUrl error "ERR_ABORTED (-3) error" can't be cached[/-] [+]loadUrl error "ERR_ABORTED (-3) error" can't be catched[/+] on Feb 1, 2021
  2. benoittgt commented on Feb 2, 2021

    @benoittgt
    Author

    Error can be catched. Do not forget loadUrl return a promise.

      win.loadURL(url).catch((error: any) => {
        if (error.code === 'ERR_ABORTED') return;
        throw error;
      });
  3. OldManMeta commented on Apr 25, 2023

    @OldManMeta

    I'm getting this error - am calling loadURL exactly how @benoittgt is showing in the last comment.

  4. OldManMeta commented on Apr 25, 2023

    @OldManMeta

    Correction - I just spotted where I was not handling this in another loadURL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions