Skip to content

Maximum call stack size exceeded for private @actions returning Futures #438

Description

@michalsuryntequiqo

Hello,

I'm developing Flutter web app using mobx (mobx: 1.0.2, flutter_mobx: 1.0.1, mobx_codegen: 1.0.2) and I'm experiencing the issue of:
Invalid argument: Maximum call stack size exceeded .
My store's code is almost identical as the github app code from repo's examples:

 List<Item> items = [];

  static ObservableFuture<List<Item>> emptyResponse = ObservableFuture.value([]);

  @observable
  ObservableFuture<List<Item>> _itemsFuture = emptyResponse;

  @computed
  bool get hasResults =>
      _itemsFuture != emptyResponse &&
      _itemsFuture.status == FutureStatus.fulfilled;


  @action
  Future<List<Item>> fetchItems() async {
    items = [];
    final future = itemsService.getAll();
   _itemsFuture = ObservableFuture(future);
    items = await future;
    return items;
  }

The problematic part seems to be the usage of @action returning a Future, because even replacing the fetchItems action with code like:

@action
 Future<List<Job>> fetchItems() async {
   items = [];
   sleep(Duration(seconds: 1));
   return items;
 }

results with the same output: Invalid argument: Maximum call stack size exceeded. Complete removal of that @action returning Future "solves" the issue, but the app does not get the data = doesn't work.

Any code change if followed by flutter clean and of course flutter packages pub run build_runner build --delete-conflicting-outputs.

What may be done wrong here?
Cheers!

Flutter doctor output:

[✓] Flutter (Channel beta, v1.14.6, on Mac OS X 10.14.6 18G3020, locale pl-PL)
 
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.5)
[✓] IntelliJ IDEA Community Edition (version 2017.3.5)
[✓] VS Code (version 1.41.1)
[✓] Connected device (3 available)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions