celest-dev / celest

The Flutter cloud platform
https://celest.dev
Other
233 stars 11 forks source link

Celest crashing when editing files #25

Closed rubenferreira97 closed 7 months ago

rubenferreira97 commented 8 months ago

Steps to reproduce:

1. Given the following code:

functions/location.dart:

Future<Location> getLocation(String name) async {
  return Location(name: name, gps: (latitude: 0.0, longitude: 0.0));
}

lib/models.dart:

typedef GPS = ({double latitude, double longitude});

class Location {
  Location({required this.name, required this.gps});
  final String name;
  GPS gps;
}

functions/location.dart:

2. Change files and Save All:

Future<Location> getLocation(String name) async {
  return Location(name: name);
}

lib/models.dart:

class Location {
  Location({required this.name});
  final String name;
}

3. See crash:

Reloading Celest...
An unexpected error occurred. A crash report has been sent to the Celest team.

This seems to happen everytime I add or remove any fields from a model.

dnys1 commented 8 months ago

Hi @rubenferreira97, sorry you are facing this issue and thanks for the detailed report.

I am taking a look and will get you an update soon. This should work, though, and I don't believe you're doing anything wrong.

dnys1 commented 8 months ago

I've released version 0.1.8 of the CLI with a fix for this (it was a simple cache invalidation issue). You can get the latest by running celest upgrade. Sorry for the hassle and please let me know if you face this problem again or any others!

rubenferreira97 commented 8 months ago

Thank you for the quick input @dnys1! This issue seems to be solved, however I think it introduced a new issue on flutter hot reload (at least this was working in previous Celest versions):

1. In flutter, change main.dart and save:

FutureBuilder(
  future: celest.functions.greeting.sayHello('Celest'), // Change 'Celest' to 'CelestA'
  builder: (_, snapshot) => switch (snapshot) {
    AsyncSnapshot(:final data?) => Text(data),
    AsyncSnapshot(:final error?) =>
      Text('${error.runtimeType}: $error'),
    _ => const CircularProgressIndicator(),
  },
),

2. App is reloaded but it still displays Hello, Celest instead of Hello, CelestA.

Sorry to bother, but I am testing this product and reporting issues because I really think it has a lot of potential!

dnys1 commented 8 months ago

Oh no! 😬

I will look into it now. No bother at all! The feedback tells me you care which is great 🥳 please don't stop!

dnys1 commented 8 months ago

Okay, I added some tests now and believe it is resolved 🤞

Would you be willing to run celest upgrade again and let me know if everything is working for you, @rubenferreira97?

rubenferreira97 commented 8 months ago

Hey @dnys1, I've upgraded to Celest 0.1.9, but I'm still encountering the flutter hot reload issue. I'm using Windows and Dart 3.3.0-279.2.beta.

Do you think there might be a stale cache causing this? I managed to get it working once by creating a new project, but subsequent attempts haven't been successful.

For future improvements, could we consider allowing user input after celest start for actions such as:

Alternatively, adding more celest commands like celest clean might be helpful.

dnys1 commented 8 months ago

Thanks for the extra information. I will continue to look into it. At the moment, I'm not able to reproduce it but I'll keep you posted as I dig more!

dnys1 commented 8 months ago

Does hot restarting the Flutter app display the correct information?

rubenferreira97 commented 8 months ago

Hey @dnys1, each time I hot reload flutter gives me a message that my application was restarted, however the old value still appears.

After testing a bit, it seems hot reload is working, but after some time it stops working randomly.

I think I have found the problem. Each time I run celest start a bunch of dart.exe and dartaoutruntime.exe instances are created.

It seems flutter keeps connected to one of these old dart.exe instances instead of the new one.

https://github.com/celest-dev/celest/assets/43851289/350b118c-c035-4192-9236-a5845a46cc10

rubenferreira97 commented 7 months ago

Hey @dnys1, do you need me to do anything else or run any additional tests to help resolve this issue? I have upgraded to Celest version 0.1.13 and this issue still happens. No pressure, just asking!

dnys1 commented 7 months ago

Hey @rubenferreira97, sorry for the radio silence. I haven't gotten a chance to dive in yet, but I should be able to look at it this weekend!

Sorry for the inconvenience, and thanks for the data you've sent so far!

dnys1 commented 7 months ago

Hi @rubenferreira97, I believe this is being caused by https://github.com/dart-lang/sdk/issues/49234. I will see what I can do to workaround it! Apologies for the delay and thanks for your patience.

dnys1 commented 7 months ago

Hi @rubenferreira97, I believe I have fixed this in the latest 0.2.0 version 😃

Would you be willing to run celest upgrade and try it out?

rubenferreira97 commented 7 months ago

I also believe this is fixed! Thanks @dnys1!