Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@firebase/firestore: Firestore (7.9.2): FIRESTORE (7.9.2) INTERNAL ASSERTION FAILED: value must be undefined or Uint8Array #2701

Closed
Gurey opened this issue Mar 1, 2020 · 5 comments

Comments

@Gurey
Copy link

Gurey commented Mar 1, 2020

[REQUIRED] Describe your environment

  • Operating System version: macOS 10.14.5
  • Browser version: N/A
  • Firebase SDK version: 8.9.2
  • Firebase Product: forestore database

[REQUIRED] Describe the problem

Getting an internal error when i try to save anything in the firestore emulator in typescript project.
I run my tests with jest ^24.9.0

Steps to reproduce:

sample.test.ts

import * as firebase from '@firebase/testing'
const app = firebase.initializeTestApp({
  projectId: 'sample-test',
  databaseName: 'test-db'
})

describe('firebase test', () => {
  test('save something', async () => {
    return app
      .firestore()
      .collection('user')
      .add({ email: '[email protected]' })
  })
})

run with firebase emulators:exec --only firestore,database "node_modules/.bin/jest --forceExit"

then i get this output:

firebase emulators:exec --only firestore,database "node_modules/.bin/jest --forceExit"
i  emulators: Starting emulators: firestore, database
i  firestore: Serving ALL traffic (including WebChannel) on http://localhost:8080
⚠  firestore: Support for WebChannel on a separate port (8081) is DEPRECATED and will go away soon. Please use port above instead.
i  firestore: Emulator logging to firestore-debug.log
✔  firestore: Emulator started at http://localhost:8080
i  firestore: For testing set FIRESTORE_EMULATOR_HOST=localhost:8080
⚠  Database rules file /Users/some/path/firebase/database.rules.json specified in firebase.json does not exist, starting Database emulator without rules.
i  database: Emulator logging to database-debug.log
✔  database: Emulator started at http://localhost:9000
i  database: For testing set FIREBASE_DATABASE_EMULATOR_HOST=localhost:9000
i  Running script: node_modules/.bin/jest --forceExit
 FAIL  src/modules/__test__/sample.test.ts
  firebase test
    ✕ save something (648ms)

  ● firebase test › save something

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

      at fail (node_modules/@firebase/firestore/src/util/assert.ts:39:9)
      at assert (node_modules/@firebase/firestore/src/util/assert.ts:48:5)
      at JsonProtoSerializer.Object.<anonymous>.JsonProtoSerializer.fromBytes (node_modules/@firebase/firestore/src/remote/serializer.ts:290:7)
      at PersistentWriteStream.Object.<anonymous>.PersistentWriteStream.onMessage (node_modules/@firebase/firestore/src/remote/persistent_stream.ts:701:44)
      at node_modules/@firebase/firestore/src/remote/persistent_stream.ts:442:21
      at node_modules/@firebase/firestore/src/remote/persistent_stream.ts:492:18
      at node_modules/@firebase/firestore/src/util/async_queue.ts:285:14

  console.error node_modules/@firebase/logger/dist/index.cjs.js:94
    [2020-03-01T21:21:03.696Z]  @firebase/firestore: Firestore (7.9.2): FIRESTORE (7.9.2) INTERNAL ASSERTION FAILED: value must be undefined or Uint8Array

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        3.173s
Ran all test suites matching /e2e/i.
Force exiting Jest: Have you considered using `--detectOpenHandles` to detect async operations that kept running after all tests finished?
⚠  Script exited unsuccessfully (code 1)
i  Shutting down emulators.
i  Stopping firestore emulator
i  Stopping database emulator

Error: Script "node_modules/.bin/jest e2e --forceExit" exited with code 1
@google-oss-bot
Copy link
Contributor

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

@SamyPesse
Copy link
Contributor

I have the same issue. It seems related to jestjs/jest#4422. I'll try some workarounds and keep you posted.

@SamyPesse
Copy link
Contributor

Using https://www.npmjs.com/package/jest-environment-uint8array fixes the issue.

@Gurey
Copy link
Author

Gurey commented Mar 2, 2020

Thank you @SamyPesse that solved my issue!

@Gurey Gurey closed this as completed Mar 2, 2020
@SamyPesse
Copy link
Contributor

Another solution is to use this jest config: https://jestjs.io/docs/en/configuration#extraglobals-arraystring

  extraGlobals: ['Uint8Array', 'ArrayBuffer']

@firebase firebase locked and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants