firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.82k stars 885 forks source link

App Check error when using emulator: "Uncaught (in promise) cancelled" #7358

Closed thdoan closed 1 year ago

thdoan commented 1 year ago

Operating System

Windows 10

Browser Version

Chrome 114

Firebase SDK Version

9.22.2

Firebase SDK Product:

AppCheck, Auth, Functions, Logger

Describe your project's tooling

No tooling right now.

Describe the problem

My app is working fine on production, but when I tried to run it locally this error was thrown:

image

I traced this error to proactive-refresh.ts:

image

My setup:

Steps and code to reproduce issue

  1. Follow instructions to enable App Check using reCAPTCHA v3 provider.
  2. Run firebase emulators:start to start the emulator.
  3. Go to http://127.0.0.1:5000/ and you should see the error in the console.

Relevant code follows...

index.html:

<!-- FirebaseUI requires namespaced SDK -->
<script src="https://www.gstatic.com/firebasejs/9.22.2/firebase-app-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.22.2/firebase-app-check-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.22.2/firebase-auth-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.22.2/firebase-functions-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/ui/6.0.2/firebase-ui-auth.js"></script>

Client script:

// Initialize Firebase
firebase.initializeApp({/* config */});
// Bypass App Check for local testing
self.FIREBASE_APPCHECK_DEBUG_TOKEN = true;
// Initialize App Check (refresh tokens automatically)
firebase.appCheck().activate(/* site key or provider */, true);
google-oss-bot commented 1 year ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

jbalidiong commented 1 year ago

Hi @thdoan, thanks for reaching out. I would like to reproduce this behavior you’re encountering. Would it be okay if you could provide me with an MCVE I can run locally, so I can have a better look into it.

thdoan commented 1 year ago

@jbalidiong thanks for offering to look into this. I'm going to close this since it's an edge case and I was able to get the errors to go away by setting up the Firebase emulator suite to authenticate locally. It seems the error only shows up when App Check fails to authenticate locally.