Skip to content

cloud_functions_web: dartify() throws "Int64 accessor not supported by dart2js" when serializing callable function request #17924

@isenbj

Description

@isenbj

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Cloud Functions

Which platforms are affected?

Web

Description

I am getting the error "Unsupported operation: Int64 accessor not supported by dart2js." when calling the code below in flutter web.

final callable = FirebaseFunctions.instance.httpsCallable('functionName');
final response = await callable.call({'id1': id1, 'id2': id2});

The network request is not being made, I have checked the network traffic in browser traffic so it is an issue in client code.

This is not an issue with local flutter builds, as local build uses dartdevc where when deployed in the release version and hosted in firebase hosting, it uses dart2js.

Reproducing the issue

  • Deploy a firebase function with inputs. Mine has 2 UUID inputs.
  • Deploy a flutter web app to firebase hosting and make a callable call to that function.
  • error

Firebase Core version

4.2.1

Flutter Version

3.35

Relevant Log Output

Int64 accessor not supported by dart2js

Flutter dependencies

No response

Additional context and comments

Workaround:

  Future<Map<String, dynamic>?> callFirebaseFunction({
    required String functionName,
    required String projectId,
    String region = 'us-central1',
    Map<String, dynamic>? parameters,
  }) async {
    final user = FirebaseAuth.instance.currentUser;
    if (user == null) {
      throw Exception('User not authenticated');
    }

    final idToken = await user.getIdToken();

    final url = 'https://$region-$projectId.cloudfunctions.net/$functionName';

    final response = await http.post(
      Uri.parse(url),
      headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer $idToken',
      },
      body: jsonEncode({
        'data': parameters ?? {},
      }),
    );

    if (response.statusCode != 200) {
      final error = jsonDecode(response.body);
      final message = error['error']?['message'] ?? 'Function call failed with status ${response.statusCode}';
      throw Exception(message);
    }

    final responseData = jsonDecode(response.body);
    return responseData['result'] as Map<String, dynamic>?;
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions