Skip to content

FIRESTORE (7.14.3) INTERNAL ASSERTION FAILED: value must be undefined or Uint8Array #3096

@rodrigoehlers

Description

@rodrigoehlers

Describe your environment

  • Operating System version: macOS Catalina Version 10.15.4
  • Browser version: None
  • Node.js version: 12.5.0
  • Firebase SDK version: 7.14.4 (implicitly through latest @firebase/testing)
  • Firebase Testing SDK version: 0.19.4
  • Firebase Product: firestore and testing
  • Jest version: 26.0.1

Describe the problem

Steps to reproduce:

Use the code below, then run tests with jest <path-to-your-file>. In my case <path-to-your-file> was ./spec/basic.spec.js.

It seems that firebase.assertFails(...) throws an error and never returns. Jest doesn't exit.

You'll receive the following logs:

(node:18117) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
 FAIL  spec/basic.spec.js
  Minimal test
    ✕ this tests throws an error and never returns (286 ms)

  ● Minimal test › this tests throws an error and never returns

    FIRESTORE (7.14.3) INTERNAL ASSERTION FAILED: value must be undefined or Uint8Array

      at fail (node_modules/@firebase/firestore/src/util/assert.ts:39:9)
      at hardAssert (node_modules/@firebase/firestore/src/util/assert.ts:53:5)
      at JsonProtoSerializer.fromBytes (node_modules/@firebase/firestore/src/remote/serializer.ts:250:7)
      at JsonProtoSerializer.fromWatchChange (node_modules/@firebase/firestore/src/remote/serializer.ts:431:32)
      at PersistentListenStream.onMessage (node_modules/@firebase/firestore/src/remote/persistent_stream.ts:568:41)
      at node_modules/@firebase/firestore/src/remote/persistent_stream.ts:448:21
      at node_modules/@firebase/firestore/src/remote/persistent_stream.ts:501:18
      at node_modules/@firebase/firestore/src/util/async_queue.ts:358:14

  console.error
    [2020-05-21T14:11:50.900Z]  @firebase/firestore: Firestore (7.14.3): FIRESTORE (7.14.3) INTERNAL ASSERTION FAILED: value must be undefined or Uint8Array

      at Logger.defaultLogHandler [as _logHandler] (node_modules/@firebase/logger/src/logger.ts:115:57)
      at Logger.error (node_modules/@firebase/logger/src/logger.ts:203:21)
      at logError (node_modules/@firebase/firestore/src/util/log.ts:45:20)
      at fail (node_modules/@firebase/firestore/src/util/assert.ts:34:3)
      at hardAssert (node_modules/@firebase/firestore/src/util/assert.ts:53:5)
      at JsonProtoSerializer.fromBytes (node_modules/@firebase/firestore/src/remote/serializer.ts:250:7)
      at JsonProtoSerializer.fromWatchChange (node_modules/@firebase/firestore/src/remote/serializer.ts:431:32)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        2.203 s
Ran all test suites matching /.\/spec\/basic.spec.js/i.
Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

Relevant Code:

Use the following as firestore.rules:

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read: if false;
      allow write: if false;
    }
  }
}

Create a minimal test, reading from a collection:

const firebase = require('@firebase/testing');

describe('Minimal test', () => {
  const projectId = 'project-id';
  let db;
  let ref;

  beforeAll(() => {
    db = firebase.initializeTestApp({ projectId }).firestore();
    ref = db.collection('hello-world');
  });

  afterAll(() => Promise.all(firebase.apps().map((app) => app.delete())));

  test('this tests throws an error and never returns', async () => {
    await expect(await firebase.assertFails(ref.get()));
  });
});

What have I tried

Downgrading @firebase/testing to version ^0.15.0 fixed the issue.

When I tested on my real rules and tests however, it seems to have broken the test reports as setValue is not in const compressedTypes = ['mapValue', 'listValue', 'constraintValue'] in the repost .html function buildValueString(...) yet? This is only speculation! It could be that my rules are simply wrong.

The report .html therefore throws the following error a couple of times:

Found invalid expression-return type.

Someone with a similar issue posted on StackOverflow.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions