Giter Club home page Giter Club logo

Comments (4)

SamyPesse avatar SamyPesse commented on June 15, 2024

This error usually come from babel when the polyfill for async/await has not been included. Requiring babel-polyfill in your script should fix it.

But I'm not sure how it works with ts-node.

I wanted to add your awesome library to our firebase/snippets-rules github repository

Thank you, I've built this library because our application has more than 1000 unit tests concerning our RTDB security rules, but we are not yet using Firestore and this library for our application, because we cannot switch to Firestore while it doesn't support validating batch updates / transactions.

I really hope Firebase would focus the next releases of Firestore on:

  • Improving the writing of security rules, current language is not very good for typing the data (see FirebaseExtended/bolt#216), Efforts like protobuf-rules-gen are more hacking than real solutions
  • Release a local emulator for security rules (that do not require sending a lot of mocked data and our rules to a remote server for each assertion)
  • Fix the batch update validation
  • Document and help developers write reliable and secure rules for their DBs, I'm ready to bet that 90% of applications built on top of Firestore have important security flaws, not because of Firebase as a platform itself but because it's poorly documented how to write secure application (almost all of your sample have "write and read everything" rules)

That being said, we love the idea of Firebase ❤️, Firestore looks like an amazing solution in theory, but it's really frustrating to invest in a tool that look mostly focused on prototypes and small projects. We sometimes feel like we are the only company trying to build a well-tested, secure application on Firebase..

from expect-firestore.

samtstern avatar samtstern commented on June 15, 2024

@SamyPesse first of all thank you for your feedback on Firestore. I hear you and I will make sure others do as well.

As for this bug:

  • I am not using Babel at all in my project
  • This appears with JS and plain-ol node as well as with TypeScript and ts-node
  • I have added babel-polyfill to my project and done require('babel-polyfill') in my code with no success

from expect-firestore.

SamyPesse avatar SamyPesse commented on June 15, 2024

first of all thank you for your feedback on Firestore. I hear you and I will make sure others do as well.

Thanks, As I've told @mcdonamp as well, we will be happy to help alpha/beta test or even contribute writing tooling to fix these issues.

As for this bug

This library is compiled with babel, and it's not advised by babel to add the polyfill for async and generator functions in each libraries (it should be in the app/script using the library).

The polyfill should be included before anything else. If you use import calls, Typescript will probably compile these imports (statics) before any require calls (runtime).

Try import 'babel-polyfill'; as the first line of your script.

This "works" for me:

import 'babel-polyfill';
import * as expectFirestore from 'expect-firestore';

const database = new expectFirestore.Database({
  credential: {},
  data: {},
  rules: ''
});

// Note: doesn't matter if this function is async or not, or if I await the promises or not
async function main() {
  await database.authorize();

  // Test a get
  await database.canGet({ uid: 'some-user' }, 'users/userA');
}

main();

It outputs:

ts-node ./test.ts
(node:51554) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: No key or keyFile set.
(node:51554) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

from expect-firestore.

samtstern avatar samtstern commented on June 15, 2024

@SamyPesse now I get it, thanks! I had to follow your advice and nuke my node_modules. Apologies for the noise, I don't leave my Android bubble often enough.

from expect-firestore.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.