Closed PhilipHayes closed 1 year ago
I was able to reproduce this issue. To reproduce I used a flutter project with mockito. Then I created a class and set up its mock. I then run monarch, which loads fine. However, after making changes to the class with the mock, monarch hot reloads and crashes.
The error seems to be related to hot reloading and the flutter desktop embedder. I will spend more time next time looking into what is causing the error.
For now, the workaround is to run monarch with the hot-restart option. Hot restarting worked fine for me. You can run monarch with the hot restart option:
monarch run --reload hot-restart
Any changes will trigger a hot restart, which is a bit slower than a hot reload but it is a workaround.
I was able to narrow down the cause of the crash. It's not related to mockito or monarch. The crash can happen under other scenarios. I created an issue in the Flutter repo: https://github.com/flutter/flutter/issues/120841
That's an incredibly detailed report, I'll definitely keep an eye out on flutter to see how they fix this.
Monarch 2.1.3 detects this crash and notifies the user of a workaround (release notes). This is the most we can do while we wait for a proper fix from the Flutter team.
Frequently Monarch will crash with this message after running just fine for a bit.
Reloading stories... ../../third_party/dart/runtime/vm/object.cc: 4717: error: Unable to use class Library:'package:mockito/src/mock.dart' Class: SmartFake which is not loaded yet. version=2.19.0 (stable) (Mon Jan 23 11:29:09 2023 -0800) on "macos_x64" pid=82637, thread=77831, isolate_group=main(0x7fcf198ace00), isolate=(nil)(0x0) os=macos, arch=x64, comp=no, sim=no isolate_instructions=10ca32b20, vm_instructions=10ca32b20 pc 0x000000010cb9a715 fp 0x00007000032a8240 dart::Profiler::DumpStackTrace(void)+0x85 pc 0x000000010ca32d94 fp 0x00007000032a8320 dart::Assert::Fail(char const, ...) const+0x84 pc 0x000000010cb1239a fp 0x00007000032a8350 dart::Class::EnsureDeclarationLoaded() const+0x6a pc 0x000000010ca73a3e fp 0x00007000032a8400 dart::ClassFinalizer::FinalizeTypesInClass(dart::Class const&)+0x3e pc 0x000000010ca73b4c fp 0x00007000032a84b0 dart::ClassFinalizer::FinalizeTypesInClass(dart::Class const&)+0x14c pc 0x000000010ca73908 fp 0x00007000032a8620 dart::ClassFinalizer::ProcessPendingClasses()+0x188
../../third_party/dart/runtime/vm/object.cc: 4717: error: Unable to use class Library:'package:mockito/src/mock.dart' Class: SmartFake which is not loaded yet. Aborting re-entrant request for stack trace. pc 0x000000010cad1523 fp 0x00007000032a8780 dart::kernel::KernelLoader::LoadProgram(bool)+0x1b3
3.1sec elapsed Unhandled exception: gRPC Error (code: 2, codeName: UNKNOWN, message: HTTP/2 error: Connection error: Connection is being forcefully terminated. (errorCode: 10), details: null, rawResponse: null, trailers: {})