-
Notifications
You must be signed in to change notification settings - Fork 928
FIRESTORE (7.14.3) INTERNAL ASSERTION FAILED: value must be undefined or Uint8Array #3096
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
Comments
Thank you for reporting this issue. I was able to reproduce and created a GitHub repository with my reproduction steps: https://github.com/dconeybe/FirebaseJsBug3096. I will look into this and update this bug with my findings. |
Wait for resolution of firebase/firebase-js-sdk#3096
Just an update that I am still investigating. I have not found the root cause yet. |
Seeing this also. Any workarounds? |
I've lost track of which packages are getting upgraded here: things under @babel, @firebase, @jest, yargs, much more. This stuff is the worst. I had to back off on some Jest upgrades since they caused (bogus?) "Do not import `@jest/globals` outside of the Jest test environment" errors in src/firebase/mock.ts that I couldn't find any way to fix. After doing this, downgrade @firebase/testing to 0.15.0, since otherwise the Firestore rules tests fail due to this bug reported 8 days ago: firebase/firebase-js-sdk#3096 Sigh.
I've lost track of which packages are getting upgraded here: things under @babel, @firebase, @jest, yargs, much more. This stuff is the worst. I had to back off on some Jest upgrades since they caused (bogus?) "Do not import `@jest/globals` outside of the Jest test environment" errors in src/firebase/mock.ts that I couldn't find any way to fix. After doing this, downgrade @firebase/testing to 0.15.0, since otherwise the Firestore rules tests fail due to this bug reported 8 days ago: firebase/firebase-js-sdk#3096 Sigh.
The issue seems to be resolved with firebase version |
I'm still seeing this with |
I'm also seeing this, but am using firebase directly not firebase-testing [email protected] |
I'm seeing this with [email protected] and "@angular/fire": "^5.4.2","firebase-tools": "^7.12.1", |
Update: Although my investigation is still in progress, here is what I have so far. It looks like this behavior may be due to a "bug" in Jest. The problem surfaces in the follow code from serializer.ts: value === undefined || value instanceof Uint8Array The My hypothesis is that the Jest testing framework is doing something wonky with "realms", an advanced feature that allows for different global memory spaces for different parts of a JavaScript program. This has come up as an issue with Jest before, and there is a potential workaround: jestjs/jest#7780. |
It looks like the workaround documented in jestjs/jest#7780 fixes the problem. I've updated my reproduction app, https://github.com/dconeybe/FirebaseJsBug3096, with the workaround steps and a Since this issue does not appear to be a bug in the Firebase SDK, but rather a side effect of how Jest executes tests, I am going to close this ticket. Feel free to re-open, however, if you disagree and we can continue the discussion. If you think of it, please report back your success with this or other workarounds. |
+1 Just came across this error with Jest as well and the workaround is perfect! Followed the workaround and all my tests worked perfectly without any problems. For others having the same issue and referring to this, use @dconeybe's workaround and your tests should run without problems again. |
Okay, so I'm not sure if this fix applies to other people or just me. But when I was designing my application, I was using Ng/Rx to manage state. I had actions, reducers, and effects designed around Firebase Auth state. I would store user info when a user was authenticated, but ALSO and here's the crucial mistake, I was also storing the credential object that gets passed in after angularFire auth login functions. To be specific I am talking about this credential object: https://firebase.google.com/docs/reference/js/firebase.auth.AuthCredential Now, it took me 6 hours, I tried all sorts of different package versions, but I finally realized the cause of this error. What happens is if I tried to make or store a copy of the credential object values, it would always lead to all kinds of Internal Firebase errors with INTERNAL ASSERTION FAILED to be only one of them. After removing any code related to reading or writing the values that came from the credential object, the error went away completely. TLDR; It looks like Firebase has some security code that causes errors when interacting with credential objects. Remove that and the Internal Assertion Failed goes away |
Sorry to bring this up again but apparently this solution does not work once you convert your tests into Typescript. I've tried converting the solution from Javascript into Typescript but it still displayed the error:
Is there something I'm missing? Because I'm pretty sure the solution provided above will work for Typescript but I'm not sure if we need to change some things up. Edit: I've resolved this problem. Solution
module.exports = {
testEnvironment: "./__test-utils__/custom-jest-environment.js",
}
|
@moscoso There's no special code for causing failures related to credential objects. So far the issue we've seen here had to do with Jest breaking globals in such a way that a value in the form of a In your first post you listed a number of dependencies and versions but did not include Jest. Was that the complete set of dependencies you're using? If so, you might be experiencing a different issue. If you could post a minimal reproduction along the lines of dconeybe's, we can help you figure out what's going on. |
@wilhuff my issue turned out to be completely separate from OP and not having to do with Jest... Maybe there is no special code for that, all I'm saying is that if you try to copy the credential object after a login method from AngularFire auth service, it will lead to INTERNAL ASSERTION FAILED.... I could re-create code if you really need me to, but it's exactly what I said. It's not longer an issue for me, removing the code that copies that credential object fixed it for me. Just letting people know if they stumble upon this thread because of the INTERNAL ASSERTION FAILED message |
For those that need
'use strict';
/**
* Correct Jest bug that prevents the Firestore tests from running. More info here:
* https://github.com/firebase/firebase-js-sdk/issues/3096#issuecomment-637584185
*/
const BrowserEnvironment = require('jest-environment-jsdom');
class MyEnvironment extends BrowserEnvironment {
constructor(config) {
super(
Object.assign({}, config, {
globals: Object.assign({}, config.globals, {
Uint32Array: Uint32Array,
Uint8Array: Uint8Array,
ArrayBuffer: ArrayBuffer
})
})
);
}
async setup() {}
async teardown() {}
}
module.exports = MyEnvironment;
|
Describe your environment
@firebase/testing
)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:
Relevant Code:
Use the following as
firestore.rules
:Create a minimal test, reading from a collection:
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 inconst 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:Someone with a similar issue posted on StackOverflow.
The text was updated successfully, but these errors were encountered: