startOnCurrentIsolate method Null safety

Future startOnCurrentIsolate()

Starts the application on the current isolate, and does not spawn additional isolates.

An application started in this way will run on the same isolate this method is invoked on. Performance is limited when running the application with this method; prefer to use start.

Implementation

Future startOnCurrentIsolate() async {
  if (server != null || supervisors.isNotEmpty) {
    throw StateError(
        "Application error. Cannot invoke 'test' on already running Conduit application.");
  }

  options.address ??= InternetAddress.loopbackIPv4;

  try {
    await _runtime!.runGlobalInitialization(options);

    server = ApplicationServer(_runtime!.channelType, options, 1);

    await server!.start();
    _hasFinishedLaunching = true;
  } catch (e, st) {
    logger.severe("$e", this, st);
    await stop().timeout(const Duration(seconds: 5));
    rethrow;
  }
}