From 922e9ed9a68c130aefa0cdb9b27720b73011c397 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 13 Jan 2022 16:23:41 -0800 Subject: [PATCH] [Auth] Fix error code thrown when the network errors out (#5892) * Fix error code thrown when the network errors out * Add changeset --- .changeset/moody-ways-learn.md | 5 +++++ packages/auth/src/api/index.test.ts | 2 +- packages/auth/src/api/index.ts | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/moody-ways-learn.md diff --git a/.changeset/moody-ways-learn.md b/.changeset/moody-ways-learn.md new file mode 100644 index 00000000000..284aff6bbc9 --- /dev/null +++ b/.changeset/moody-ways-learn.md @@ -0,0 +1,5 @@ +--- +"@firebase/auth": patch +--- + +Fix error code thrown when the network times out diff --git a/packages/auth/src/api/index.test.ts b/packages/auth/src/api/index.test.ts index 47dbf228630..3f0b0ee9305 100644 --- a/packages/auth/src/api/index.test.ts +++ b/packages/auth/src/api/index.test.ts @@ -316,7 +316,7 @@ describe('api/_performApiRequest', () => { request ); clock.tick(DEFAULT_API_TIMEOUT_MS.get() + 1); - await expect(promise).to.be.rejectedWith(FirebaseError, 'auth/timeout'); + await expect(promise).to.be.rejectedWith(FirebaseError, 'auth/network-request-failed'); clock.restore(); }); diff --git a/packages/auth/src/api/index.ts b/packages/auth/src/api/index.ts index bff8f633a13..f727d8d2f66 100644 --- a/packages/auth/src/api/index.ts +++ b/packages/auth/src/api/index.ts @@ -223,7 +223,7 @@ class NetworkTimeout { private timer: any | null = null; readonly promise = new Promise((_, reject) => { this.timer = setTimeout(() => { - return reject(_createError(this.auth, AuthErrorCode.TIMEOUT)); + return reject(_createError(this.auth, AuthErrorCode.NETWORK_REQUEST_FAILED)); }, DEFAULT_API_TIMEOUT_MS.get()); });