flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

[firebase_core]: Error Encountered After Upgrading Firebase Core to v2.30.1: Invalid Conditional Import in _flutterfire_internals Package

Open isaacadariku opened this issue 1 year ago • 14 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues.

Which plugins are affected?

Core

Which platforms are affected?

No response

Description

After upgrading Firebase Core from version 2.27.0 to version 2.30.1, running the build runner resulted in the following error in the log output.

The error originates from the _flutterfire_internals package v1.3.32. Downgrading the package to v1.3.31 by overriding it, resolved the error. It's noted that the error was addressed in a merged pull request: PR #12698, which was released in version 1.3.32.

Expected Behavior

The build runner should execute without errors.

Current Behavior

The build runner fails with the reported error.

Reproducing the issue

Upgrade Firebase Core to version 2.30.1. Using the latest build_runner: ^2.4.9 Run the build runner dart run build_runner build --delete-conflicting-outputs

Firebase Core version

2.30.1

Flutter Version

3.19.6

Relevant Log Output

[SEVERE] build_modules:module_library on package:_flutterfire_internals/_flutterfire_internals.dart (cached):

Invalid argument(s): Unsupported conditional import of `dart:js_interop` found in _flutterfire_internals|lib/_flutterfire_internals.dart:

import 'src/interop_shimmer.dart' if (dart.library.js_interop) 'dart:js_interop' as js_interop;

This environment does not support direct conditional imports of `dart:` libraries. Instead you must create a separate library which unconditionally imports (or exports) the `dart:` library that you want to use, and conditionally import (or export) that library.
[SEVERE] Failed after 1m 28s

Flutter dependencies

Expand Flutter dependencies snippet

Replace this line with the contents of your `flutter pub deps -- --style=compact`.

Additional context and comments

No response

isaacadariku avatar Apr 25 '24 15:04 isaacadariku

Thanks for the report I'm looking into it, have you tried to exclude this particular file in your build.yaml file?

Lyokone avatar Apr 26 '24 08:04 Lyokone

Screenshot 2024-04-26 at 10 18 12

I cannot reproduce the issue, could you give a complete sample?

Lyokone avatar Apr 26 '24 08:04 Lyokone

hello @Lyokone ,

my comment not related to mentioned issue, but if I can please ask to do another version release to include 10.11.1 firebase js library https://firebase.google.com/support/release-notes/js to resolve following issue https://github.com/firebase/firebase-js-sdk/pull/8145 which is long running annoying problem for my flutter app, please help 🙏

alex-dokienko avatar Apr 27 '24 13:04 alex-dokienko

Same error here:

Deprecated. Use `dart run` instead.
[INFO] Generating build script completed, took 188ms
[INFO] Setting up file watchers completed, took 4ms
[INFO] Waiting for all file watchers to be ready completed, took 676ms
[INFO] Reading cached asset graph completed, took 876ms
[INFO] Checking for updates since last build completed, took 1.1s
[INFO] Running build completed, took 247ms
[INFO] Caching finalized dependency graph completed, took 898ms
[SEVERE] build_modules:module_library on package:_flutterfire_internals/_flutterfire_internals.dart (cached):

Invalid argument(s): Unsupported conditional import of `dart:js_interop` found in _flutterfire_internals|lib/_flutterfire_internals.dart:

import 'src/interop_shimmer.dart' if (dart.library.js_interop) 'dart:js_interop' as js_interop;

This environment does not support direct conditional imports of `dart:` libraries. Instead you must create a separate library which unconditionally imports (or exports) the `dart:` library that you want to use, and conditionally import (or export) that library.
[SEVERE] Failed after 1.2s

@Lyokone pinning 2.30.0 solves it.

  firebase_core: 2.30.0
  firebase_messaging: ^14.8.0

rokk4 avatar Apr 27 '24 15:04 rokk4

I ran into this too. Updating to the latest versions of all the Flutter Firebase packages solved the error for me.

elitree avatar Apr 28 '24 21:04 elitree

For some reason, updating to the latest Firebase packages worked earlier, but now I'm getting the same error again, even with all the latest packages.

Pinning _flutterfire_internals to 1.3.31 solves the error for me.

elitree avatar May 01 '24 18:05 elitree

Hey @isaacadariku. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar May 10 '24 01:05 google-oss-bot

The issue still happen with firebase_core: 2.31.0

ciprig avatar May 10 '24 10:05 ciprig

@Lyokone Thanks for the response. I have not tried excluding the file in the build.yaml file. Can you provide an example of excluding the file in the build.yaml file? As this file is part of the _flutterfire_internals package, I am not sure how to exclude it.

I will try to create a sample project to reproduce the issue and share it with you.

isaacadariku avatar May 10 '24 10:05 isaacadariku

Thanks, waiting for your sample project @isaacadariku

Lyokone avatar May 28 '24 09:05 Lyokone

Hi @isaacadariku, I was running into this issue as well, and have a small workaround which I might submit as a PR if it works for you too. Can you see if that's the case?

dependency_overrides:
  _flutterfire_internals:
    git:
      url: https://github.com/elitree/flutterfire.git
      path: packages/_flutterfire_internals
      ref: fix-web-build-error

Hi @Lyokone, I'm still not 100% sure how this is happening in my build.yaml, but I believe it has to do with some reference build_web_compilers code from the drift project for using web workers that I'm using in my project. It seems that the dart2js compilation from that reference code doesn't play nicely with the direct dart:js_interop import added in #12698. Based on this other similar issue, I tried using an indirect import for the workaround mentioned above, and that fixed my build error.

I apologize that I'm still not sure how to reproduce the original example, but my guess based on the above is it would involve adding a builder using the build_web_compilers package and dart2js. Thanks

elitree avatar May 31 '24 19:05 elitree

Hi @isaacadariku, I was running into this issue as well, and have a small workaround which I might submit as a PR if it works for you too. Can you see if that's the case?

dependency_overrides:
  _flutterfire_internals:
    git:
      url: https://github.com/elitree/flutterfire.git
      path: packages/_flutterfire_internals
      ref: fix-web-build-error

Hi @Lyokone, I'm still not 100% sure how this is happening in my build.yaml, but I believe it has to do with some reference build_web_compilers code from the drift project for using web workers that I'm using in my project. It seems that the dart2js compilation from that reference code doesn't play nicely with the direct dart:js_interop import added in #12698. Based on this other similar issue, I tried using an indirect import for the workaround mentioned above, and that fixed my build error.

I apologize that I'm still not sure how to reproduce the original example, but my guess based on the above is it would involve adding a builder using the build_web_compilers package and dart2js. Thanks

@elitree I am also using drift and have a web project. I think you could be on to something there.

rokk4 avatar Jun 07 '24 12:06 rokk4

Hi @Lyokone, I submitted the above PR to resolve this issue. But I totally understand if you'd rather wait for a minimal reproducible example before looking at the PR, so let me know if that's the case. Thanks.

elitree avatar Jun 07 '24 15:06 elitree

Hey @isaacadariku. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Jun 18 '24 01:06 google-oss-bot

Quick note that https://github.com/firebase/flutterfire/pull/12925 is submitted to fix this issue. Thanks…

elitree avatar Jun 30 '24 23:06 elitree

Since there haven't been any recent updates here, I am going to close this issue.

@isaacadariku if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

google-oss-bot avatar Jul 09 '24 01:07 google-oss-bot

Can we leave this open until #12925 is merged to fix the issue?

elitree avatar Jul 09 '24 01:07 elitree

A fix from @elitree is almost ready to be merged to fix this. Hey, @google-oss-bot, please re-open the issue 😄

isaacadariku avatar Jul 09 '24 05:07 isaacadariku

The PR is now merged

TarekkMA avatar Jul 09 '24 09:07 TarekkMA