From 231c510f867e8b0f024b443e24bda82c76e5bc1b Mon Sep 17 00:00:00 2001 From: Evan Morikawa Date: Sat, 14 Jan 2017 17:51:02 -0800 Subject: [PATCH] fix(auth): fix unnecessarly loud api errors Summary: Fixes T7520 Gets rid of the Gmail auth error too Test Plan: manual Reviewers: juan Reviewed By: juan Maniphest Tasks: T7520 Differential Revision: https://phab.nylas.com/D3688 --- .../onboarding/lib/onboarding-helpers.es6 | 10 +++++++++- src/flux/stores/account-store.es6 | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/internal_packages/onboarding/lib/onboarding-helpers.es6 b/internal_packages/onboarding/lib/onboarding-helpers.es6 index 93dd859b4..8c27e635f 100644 --- a/internal_packages/onboarding/lib/onboarding-helpers.es6 +++ b/internal_packages/onboarding/lib/onboarding-helpers.es6 @@ -50,7 +50,15 @@ export async function makeGmailOAuthRequest(sessionKey, callback) { auth: noauth, }, }); - const remoteJSON = await remoteRequest.run() + let remoteJSON = {} + try { + remoteJSON = await remoteRequest.run() + } catch (err) { + if (err.statusCode === 404) { + return + } + throw err + } const localRequest = new NylasAPIRequest({ api: NylasAPI, options: { diff --git a/src/flux/stores/account-store.es6 b/src/flux/stores/account-store.es6 index e455e3d93..f8b2941b3 100644 --- a/src/flux/stores/account-store.es6 +++ b/src/flux/stores/account-store.es6 @@ -236,6 +236,12 @@ class AccountStore extends NylasStore { const existing = this.accountForId(accountId) if (!existing) return // user may have deleted existing.fromJSON(json) + }).catch((err) => { + console.error(err); + // Dont't throw here. If this function gets run immediately at + // boot it may try before local-sync is ready. This is okay as + // we'll refresh the accounts later anyway. We'll also be + // eventually deprecating this API to merge it with K2 }) })).finally(() => { this._caches = {}