Skip to content

fix(core,web): compile isA checks on Dart < 3.12 - #18612

Open
SelaseKay wants to merge 2 commits into
mainfrom
fix/18611-core-web-isa-compat
Open

fix(core,web): compile isA checks on Dart < 3.12#18612
SelaseKay wants to merge 2 commits into
mainfrom
fix/18611-core-web-isa-compat

Conversation

@SelaseKay

Copy link
Copy Markdown
Contributor

Summary

Why is! JSError instead of isA

#18552 added e.isA<JSObject>() on catch (e) so we could distinguish JS Firebase errors from Dart exceptions without an invalid_runtime_check_with_js_interop_types ignore.

That only compiles on Dart ≥ 3.12. isA lived on JSAny? until 3.12, when it moved to NullableObjectUtilExtension on Object? (Dart changelog). catch (e) types e as Object, so on Dart 3.6–3.11 the extension does not apply.

FlutterFire CI did not catch this: web jobs run on floating stable (currently Flutter 3.44 / Dart 3.12). Users still on Flutter 3.35 / 3.38 (Dart 3.9 / 3.10) — which sdk: ^3.6.0 still allows — cannot compile for web.

Raising the constraint to ^3.12.0 would “fix” the compile error by refusing to resolve on those SDKs. That would drop Flutter 3.35/3.38, which is a much larger break than this patch.

So this PR uses e is! JSError with the same lint ignore already used in FlutterFire web (firebase_auth_web, cloud_functions_web, and this file’s flutterfire_ignore_scripts path). That:

We do not use (e as JSAny).isA<JSObject>() to keep calling isA. That recasts Dart exceptions into JS types and can reintroduce the #18548 TypeError, especially on dart2wasm.

Test plan

isA is only available on Object? from Dart 3.12, but catch (e) is Object
and firebase_core_web still supports sdk ^3.6.0. Use is! JSError so web
still compiles on Flutter 3.35/3.38 without raising the SDK constraint.
@gemini-code-assist

Copy link
Copy Markdown
Contributor
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[core]: firebase_core_web 3.11.0 fails to compile for web — isA<JSObject>() called on Object-typed catch variable

2 participants