Skip to content

Commit

Permalink
fix: Ignore oAuth2 exception on redirect of initial url load (Kong#5926
Browse files Browse the repository at this point in the history
…) (Kong#6120)

* fix: Ignore oAuth2 exception on redirect of initial url load (Kong#5926)

* use if

---------

Co-authored-by: jackkav <jackkav@gmail.com>
  • Loading branch information
chrisjq and jackkav committed Nov 24, 2023
1 parent ba78d53 commit 3dc6b5e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/insomnia/src/main/authorizeUserInWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ export enum ChromiumVerificationResult {
USE_CHROMIUM_RESULT = -3
}

export enum URLLoadErrorCodes {
/**
* An operation was aborted (due to user action).
* Error code generated from Electron or Chromium. e.g. redirect
* - https://www.electronjs.org/docs/latest/api/web-contents#event-did-fail-load
* - https://source.chromium.org/chromium/chromium/src/+/main:net/base/net_error_list.h
*/
ERR_ABORTED = -3
}

export function authorizeUserInWindow({
url,
urlSuccessRegex = /(code=).*/,
Expand Down Expand Up @@ -130,6 +140,10 @@ export function authorizeUserInWindow({
try {
await child.loadURL(url);
} catch (error) {
// Ignore the error as the initial url load was aborted on redirect.
if (error.errno === URLLoadErrorCodes.ERR_ABORTED) {
return;
}
// Reject with error to show result in OAuth2 tab
reject(error);
// Need to close child window here since an exception in loadURL precludes normal call in
Expand Down

0 comments on commit 3dc6b5e

Please sign in to comment.