redolent
redolent

Reputation: 4259

Firebase: strange error: Operation cancelled

I cannot use firebase in my app. Except for functions. Please halpp

When I run the code below from command-line (via node), it works just fine. When I run it from web, I get the following error:

Uncaught (in promise) FirebaseError: Operation cancelled

Here is the code:

const firebase   =  require('firebase/app');
const firestore  =  require('firebase/firestore');

var collection = firebase.firestore().collection( 'test_entries' );
collection.add(
    {
        'gerd': 'dernit'
    }
);

Right below the line causing throwing the exception is this comment:

// HACK: We write a toString property directly because Error is not a real
// class and so inheritance does not work correctly. We could alternatively
// do the same "back-door inheritance" trick that FirebaseError does.

If that helps, the source is: https://github.com/firebase/firebase-js-sdk/blob/master/packages/firestore/src/util/error.ts#L171

I checked the headers:

access-control-allow-origin: http://localhost

So, it's not a cors issue, I guess?

Thank you very much for any help! I've been working on this issue for a while.

Upvotes: 1

Views: 990

Answers (2)

Ajay Jagtap
Ajay Jagtap

Reputation: 21

Recently I came across same issue.

I fixed it by deleting firebaseLocalStorageDb from IndexedDB under Application in browsers Developer tools.

When you make any changes in your firebase DB, You need to do above steps else it is connecting to previous version of Database (firebaseLocalStorageDb) and your latest changes will not reflect

Upvotes: 0

NO_GUI
NO_GUI

Reputation: 464

Hmm there's a warning about using firebase like that in the documentation: https://firebase.google.com/docs/web/setup that says using the requires in node.js only for, "Firebase JavaScript SDK as a client for end-user access (for example, in a Node.js desktop or IoT application)" making it sound like you can't use them by connecting and running it from the website.

Upvotes: 2

Related Questions