Skip to content

[Bug]: Browser panel shows navigate.loadURL error when a page redirects while still loading #28788

Closed

Description

@Javerto

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/desktop

Steps to reproduce

  1. Run a page that starts a client-side redirect while one of its resources is still loading:
// server.js: node server.js
require("http").createServer((req, res) => {
  if (req.url === "/slow.png") return setTimeout(() => { res.statusCode = 404; res.end(); }, 1500);
  res.setHeader("content-type", "text/html");
  if (req.url === "/") return res.end('<script>location.href="/target"</script><img src="/slow.png">');
  res.end("<title>target</title>target");
}).listen(3456);
  1. Open the T3 Code browser panel.
  2. Enter http://localhost:3456/ in the address bar.

I hit this on a real site whose sign-in flow redirects to an OIDC /connect/authorize endpoint. I confirmed the trigger with the page above against plain Electron 44.10.0 (see Logs), but I did not run this exact page through the T3 Code UI.

Expected behavior

The tab follows the redirect and no error is shown, as in a normal browser. The redirect is ordinary page behavior and the navigation succeeds.

Actual behavior

The page opens at the redirect target, but T3 Code reports a failure:

Error invoking remote method 'desktop:preview-navigate': PreviewOperationError: Desktop preview operation failed: navigate.loadURL (tab [...], WebContents 2)

The cause appears to be that navigate passes on every wc.loadURL(url) rejection:

yield* attemptPromise({ operation: "navigate.loadURL", tabId, webContentsId: wc.id }, () =>

loadURL rejects with ERR_ABORTED (-3) when a new main-frame navigation starts before the first load finishes, so a superseded load is reported as a failed one. The did-fail-load handler in the same file already ignores this code:

if (code === -3 || !isMainFrame) return;

Treating a superseded ERR_ABORTED in navigate the same way looks like the matching fix.

Impact

Minor bug or occasional failure

Version or commit

v0.1.6 (the same code is on main @ 3fd2b85)

Environment

Windows 11 Pro 10.0.26200, T3 Code (Beta) 0.1.6 desktop app, Electron 44.10.0

Logs or stack traces

# desktop.trace.ndjson, URL parameters and local paths redacted
PreviewOperationError: Desktop preview operation failed: navigate.loadURL (tab [...], WebContents 2)
    at PreviewManager.navigate (...\apps\desktop\dist-electron\main.cjs:147898:34)
    at desktop.ipc.preview.navigate (...\apps\desktop\dist-electron\main.cjs:69250:73)
  [cause]: Error: ERR_ABORTED (-3) loading 'https://<identity-provider>/connect/authorize?<redacted>'
      at rejectAndCleanup (node:electron/js2c/browser_init:1:96591)
      at WebContents.navigationListener (node:electron/js2c/browser_init:1:96871)
      at WebContents.emit (node:events:526:24)

# Plain Electron 44.10.0, webContents.loadURL() on a local server. Same result in 3 of 3 runs.
# "slow" = page also has an <img> that takes 1.5s to respond.
/inline-slow   location.href, slow resource          REJECTED ERR_ABORTED (-3) loading '/target'   final: /target
/timer-slow    setTimeout + location.href, slow      REJECTED ERR_ABORTED (-3) loading '/target'   final: /target
/fetch-slow    fetch().then(location.href), slow     REJECTED ERR_ABORTED (-3) loading '/target'   final: /target
/inline-fast   location.href, no slow resource       RESOLVED                                      final: /target
/timer-noslow  setTimeout + location.href, no slow   RESOLVED                                      final: /target
/meta-slow     meta refresh, slow resource           RESOLVED                                      final: /target
/hash-slow     location.hash change, slow resource   RESOLVED                                      final: /hash-slow#x
/302           server redirect (separate run)        RESOLVED                                      final: /target

Workaround

None needed. The page loads correctly, so the error can be dismissed.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions