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_database] Crashes when querying with .equalTo(null).onValue - method not found: 'apply' on null #9091

Closed
dnkoulouris opened this issue Jul 13, 2022 · 15 comments · Fixed by #9251
Assignees
Labels
platform: web Issues / PRs which are specifically for web. plugin: database resolution: fixed A fix has been merged or is pending merge from a PR. type: bug Something isn't working type: crash A compile error or crash

Comments

@dnkoulouris
Copy link

When I query something like this db.ref().child('XXX').child(XXX).orderByChild('XXX').equalTo(null).onValue
I get the following error: Uncaught TypeError: Cannot read properties of undefined (reading 'apply'), NoSuchMethodError: method not found: 'apply' on null

This exists after upgrading to the latest version 9.0.19. If I revert my firebase packages to the previous versions, it works normally.

Screenshot 2022-07-13 at 5 12 26 PM

P.S. I migrated from index.html initialization to the new in-dart FlutterFire CLI initialization, and removed all the firebase related code from the .html files.

@dnkoulouris dnkoulouris added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Jul 13, 2022
@darshankawar darshankawar added the triage Issue is currently being triaged. label Jul 14, 2022
@darshankawar
Copy link

@dnkoulouris
Can you provide flutter doctor -v, complete error log in text format instead of in screenshot along with a minimal complete code sample that triggers this error ?

This exists after upgrading to the latest version 9.0.19. If I revert my firebase packages to the previous versions, it works normally.

Does reverting firebase_database to previous version works or you have to revert other flutterfire plugins as well ?
Can you provide pubspec.yaml ?

@darshankawar darshankawar added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Jul 14, 2022
@dnkoulouris
Copy link
Author

The strange thing is that this issue does not exist in debug builds (I have to deploy to my test server).

[✓] Flutter (Channel stable, 3.0.4, on macOS 12.4 21F79 darwin-x64, locale
    en-GR)
    • Flutter version 3.0.4 at /Users/denkoul/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 85684f9300 (2 weeks ago), 2022-06-30 13:22:47 -0700
    • Engine revision 6ba2af10bb
    • Dart version 2.17.5
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version
    33.0.0-rc1)
    • Android SDK at /Users/denkoul/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0-rc1
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      11.0.12+0-b1504.28-7817840)

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 12.4 21F79 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 103.0.5060.114
    ! Error: denkoul-iPhone is not connected. Xcode will continue when
      denkoul-iPhone is connected. (code -13)

[✓] HTTP Host Availability
    • All required HTTP hosts are available

This happens when I upgrade all the libraries to the new version.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Jul 14, 2022
@darshankawar
Copy link

Thanks for the update @dnkoulouris
Can you provide below as requested earlier ?

complete error log in text format instead of in screenshot along with a minimal complete code sample that triggers this error ?

This happens when I upgrade all the libraries to the new version.

What version were you on earlier and which plugins did you upgrade to latest ?

@darshankawar darshankawar added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Jul 15, 2022
@dnkoulouris
Copy link
Author

dnkoulouris commented Jul 18, 2022

Update: I updated firebase libs to the latest versions and left firebase_database to the previous one (9.0.18).
Same error. Console log:

js_helper.dart:1124 Uncaught TypeError: Cannot read properties of undefined (reading 'apply')
    at Object.callMethod (js_util.dart:92:3)
    at Query0._createQueryConstraint$1$2 (utils.dart:100:10)
    at Query0._createQueryConstraint$2 (database.dart:457:6)
    at QueryWeb__getQueryDelegateInstance_closure.call$1 (database.dart:440:21)
    at Interceptor.forEach$1 (js_array.dart:316:7)
    at DatabaseReferenceWeb._getQueryDelegateInstance$1 (query_web.dart:20:15)
    at DatabaseReferenceWeb.observe$2 (query_web.dart:95:39)
    at Query.get$onValue (query.dart:72:7)
    at Object.NotificationsRepository_listenToNotifications (notifications_repository.dart:12:94)
    at NotificationsService.listenForNotifications$0 (notifications_service.dart:75:5)

Code sample:

db.ref().child('notifications').child(userId).orderByChild('ackAt').equalTo(null).onValue.map((event) {

PS: I removed all the firebase related scripts in the index.html and used only the flutterfire configure command. I am also using separate database location rather than the default one (default is US, I am providing the EU link in the firebase_options file).

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Jul 18, 2022
@darshankawar
Copy link

Thanks for the update. This seems to be an issue with firebase_core_web and web js sdk's v9 for which there have been similar issues reported already:

#9097
#9106

firebase js sdk issue to follow-up for reference: firebase/firebase-js-sdk#6445

@darshankawar darshankawar added plugin: database platform: web Issues / PRs which are specifically for web. type: crash A compile error or crash and removed Needs Attention This issue needs maintainer attention. triage Issue is currently being triaged. labels Jul 19, 2022
@Dararii
Copy link

Dararii commented Jul 21, 2022

I have similar issue, my firebase SDK version is 9.9.0

@binlebin
Copy link

I have a similar issue.

@Lyokone Lyokone self-assigned this Jul 22, 2022
@Lyokone
Copy link
Contributor

Lyokone commented Jul 22, 2022

Hello :)
I'm unable to reproduce this, can you give a complete example so I can see what's going on?

@russellwheatley russellwheatley added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Jul 25, 2022
@ScottWallace
Copy link

Update: I updated firebase libs to the latest versions and left firebase_database to the previous one (9.0.18). Same error. Console log:

js_helper.dart:1124 Uncaught TypeError: Cannot read properties of undefined (reading 'apply')
    at Object.callMethod (js_util.dart:92:3)
    at Query0._createQueryConstraint$1$2 (utils.dart:100:10)
    at Query0._createQueryConstraint$2 (database.dart:457:6)
    at QueryWeb__getQueryDelegateInstance_closure.call$1 (database.dart:440:21)
    at Interceptor.forEach$1 (js_array.dart:316:7)
    at DatabaseReferenceWeb._getQueryDelegateInstance$1 (query_web.dart:20:15)
    at DatabaseReferenceWeb.observe$2 (query_web.dart:95:39)
    at Query.get$onValue (query.dart:72:7)
    at Object.NotificationsRepository_listenToNotifications (notifications_repository.dart:12:94)
    at NotificationsService.listenForNotifications$0 (notifications_service.dart:75:5)

Code sample:

db.ref().child('notifications').child(userId).orderByChild('ackAt').equalTo(null).onValue.map((event) {

PS: I removed all the firebase related scripts in the index.html and used only the flutterfire configure command. I am also using separate database location rather than the default one (default is US, I am providing the EU link in the firebase_options file).

I'm also using a separate database location rather than the default one, and having this issue. Perhaps that's a pattern, and explains why it can't be easily reproduced.

@Dararii
Copy link

Dararii commented Jul 25, 2022

In my case, the problem did not occur in debug build, but occur on release build (Flutter for Web).

@ScottWallace
Copy link

In my case, the problem did not occur in debug build, but occur on release build (Flutter for Web).

Same here. Perhaps we have four patterns: 1) Use of separate database location, 2) issue occurs only with release build, 3) issue only manifests for web, and 4) builds without issue or warning, error only occurs at release run-time. @Lyokone, that's likely why you couldn't reproduce this.

It's a strong block for me, can't release the latest update without this.

@Dararii
Copy link

Dararii commented Jul 26, 2022

@Lyokone Any update on this issue?

Or any workaround I can do?

@deepak786
Copy link
Contributor

Same issue in profile and release mode only.
Working fine in debug build.

@ScottWallace
Copy link

Apparently, this thread is labeled as "waiting for customer response", so, no attention. @Lyokone, @russellwheatley, @darshankawar, others, can you tell us what further information you need before you move on this? We've delayed a release for a week waiting for at least some kind of work-around. This is a hard stop, we need some attention here.

@Lyokone
Copy link
Contributor

Lyokone commented Jul 28, 2022

@ScottWallace we're waiting for a full repro as I was unable to reproduce with the provided information. A similar thing happen in Cloud Firestore and was due to dart2js issue.

The workaround you can try is to release with flutter build web --debug even tho it's not ideal.

@darshankawar darshankawar added resolution: fixed A fix has been merged or is pending merge from a PR. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Jul 29, 2022
@firebase firebase locked and limited conversation to collaborators Aug 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform: web Issues / PRs which are specifically for web. plugin: database resolution: fixed A fix has been merged or is pending merge from a PR. type: bug Something isn't working type: crash A compile error or crash
Projects
None yet
9 participants