Skip to content
This repository has been archived by the owner on Mar 18, 2021. It is now read-only.

Unable to spawn isolate in 4.0.0-b1 #916

Closed
tedwong opened this issue Nov 22, 2020 · 5 comments
Closed

Unable to spawn isolate in 4.0.0-b1 #916

tedwong opened this issue Nov 22, 2020 · 5 comments

Comments

@tedwong
Copy link

tedwong commented Nov 22, 2020

Did anyone encounter this issue:

aqueduct db generate
-- Aqueduct CLI Version: 4.0.0-b1
-- Aqueduct project version: 4.0.0-b1
Replaying versions: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47...
*** Uncaught error
IsolateSpawnException: Unable to spawn isolate: ../../../../../../../../.pub-cache/hosted/pub.dartlang.org/isolate_executor-2.0.2+3/lib/src/source_generator.dart:6:8: Error: Error when reading '../../../../../../../../.pub-cache/hosted/pub.dartlang.org/analyzer-0.41.0/lib/analyzer.dart': No such file or directory
import 'package:analyzer/analyzer.dart';
^
../../../../../../../../.pub-cache/hosted/pub.dartlang.org/isolate_executor-2.0.2+3/lib/src/source_generator.dart:54:17: Error: Type 'ClassDeclaration' not found.
static Future _getClass(Type type) async {
^^^^^^^^^^^^^^^^
../../../../../../../../.pub-cache/hosted/pub.dartlang.org/isolate_executor-2.0.2+3/lib/src/source_generator.dart:57:22: Error: Method not found: 'parseDartFile'.
final fileUnit = parseDartFile(uri.toFilePath(windows: Platform.isWindows));
^^^^^^^^^^^^^
../../../../../../../../.pub-cache/hosted/pub.dartlang.org/isolate_executor-2.0.2+3/lib/src/source_generator.dart:61:28: Error: 'ClassDeclaration' isn't a type.
.where((u) => u is ClassDeclaration)
^^^^^^^^^^^^^^^^
../../../../../../../../.pub-cache/hosted/pub.dartlang.org/isolate_executor-2.0.2+3/lib/src/source_generator.dart:62:28: Error: 'ClassDeclaration' isn't a type.
.map((cu) => cu as ClassDeclaration)
^^^^^^^^^^^^^^^^
**** Stacktrace


@tedwong
Copy link
Author

tedwong commented Nov 23, 2020

Here is the solution I do to temporarily resolve the issue, for long term, I think need some source code update.

  1. Make sure you are using Dart SDK 2.8.4 or below.
    Jairo in Slack group recommended using a tools call fd_console can easily switch the Dart SDK:
    https://github.com/jairoFernandez/commons

u can use fd_console dart_sdk 2.8.4 to install the old version dartm and use fd_console set_dark_sdk 2.8.4 to switch to 2.8.4, or download the least dart SDK and switch between them.

  1. Then, you need to check out all of these projects:
    aqueduct-4.0.0-b1
    runtime-1.0.0-9
    dart-isolate-executor-master
    safe_config-3.0.0-b2

All these projects can be found on git, or if u pub get before, u should able to find it on ~/.pub-cache/hosted/pub.dartlang.org

After you get the project, personally suggest you place in <your project path>/vendors/.

  1. Then, you need to open aqueduct-4.0.0-b1 and update the pubspec.yaml as follow:
dependencies:
  args: ^1.5.0
  analyzer: '>=0.39.4 <0.40.0'
  crypto: ^2.0.6
  logging: ^0.11.3
  meta: ^1.1.5
  open_api: ^2.0.1
  password_hash: ^2.0.0
  path: ^1.6.1
  postgres: ^2.1.1
  pub_cache: '>=0.2.0 <0.3.0'
  pub_semver: ^1.4.0
  yaml: ^2.1.15
  runtime: 
    path: ../../runtime-1.0.0-9
  isolate_executor: 
    path: ../../dart-isolate-executor-master
  safe_config: 
    path: ../../safe_config-3.0.0-b2

dev_dependencies:
  matcher: '>=0.12.3 <0.14.0'
  test: ^1.3.0
  http: '>=0.11.3+7 <0.13.0'
  command_line_agent: ^1.0.0-b2
  aqueduct_test:
    path: ../aqueduct_test

Then, you need to open runtime-1.0.0-9 and update the pubspec.yaml as follow:

dependencies:
  analyzer: '>=0.32.0 <0.40.0'
  args: ^1.5.0
  pubspec_parse: '>=0.1.4 <1.0.0'
  isolate_executor: 
      path: ../dart-isolate-executor-master
  meta: ^1.1.5
  yaml: ^2.1.15

Then, you need to open dart-isolate-executor-master and update the pubspec.yaml as follow:

dependencies:
  analyzer: '>=0.32.0 <0.40.0'

Then, you need to open safe_config-3.0.0-b2 and update the pubspec.yaml as follow:

dependencies:
  yaml: '>=2.1.8 <3.0.0'
  runtime: 
      path: ../runtime-1.0.0-9

  1. You will noticed that the main issue is caused by the analyzer library. u can "hack" the analyzer in your ~/.pub-cache/hosted/pub.dartlang.org, but I think this manually handling can avoid lots of mistakes. Anyway, after you update all the pubspec.yaml u can install the the aqueduct-4.0.0-b1 using this cmd:

pub global activate --source path <your project path>/vendors/aqueduct-master/aqueduct

After that, u should able to run your aqueduct-4.0.0-b1.

Hopefully the project will update very soon. It is such a pain and time waste to find out all the dependencies and fix it in a manually way.

@Reductions
Copy link
Contributor

Reductions commented Nov 23, 2020

The thing you do is a lot of work for not that big of a reward.
First I would recommend you use asdf-vm instead of fd_console it is much better tool.

All you have to do for the project to run (even with the lastest SDK is to clone it localy and activate the aqueduct from the source directory).
Alternatively as you already have an aqueduct project you can just override the aqueduct dependency to point at aqueduct master head. And instead of aqueduct db generete you will be able to use pub run aqueduct db generate.

@riekusr
Copy link

riekusr commented Dec 25, 2020

The thing you do is a lot of work for not that big of a reward.
First I would recommend you use asdf-vm instead of fd_console it is much better tool.

All you have to do for the project to run (even with the lastest SDK is to clone it localy and activate the aqueduct from the source directory).
Alternatively as you already have an aqueduct project you can just override the aqueduct dependency to point at aqueduct master head. And instead of aqueduct db generete you will be able to use pub run aqueduct db generate.

anyone to care to provide some more details on how to do this?

@Axort
Copy link

Axort commented Dec 30, 2020

What I did was:

Execute this inside the directory you want Aqueduct to be downloaded -> git clone git@github.com:stablekernel/aqueduct.git

I, for example, did it in a different directory, alongside my project:

/my_project
/vendors // I cloned it here.

Then, in your project's pubspec.yaml:

aqueduct:
     path: ../vendors/aqueduct/aqueduct/

Then in your project you can execute all commands with pub run as a prefix, for example:

pub run aqueduct serve
pub run aqueduct document client

All of this is what @Reductions suggested and worked perfectly.

@riekusr
Copy link

riekusr commented Jan 15, 2021

@Axort thank you for your reply. Did you downgrade dart SDK for this? got everthing running 2 weeks ago after lots of fiddling, but was probably stilll on an older dart SDK. I had to reinstall dart and now I can't get aqueduct working.

I do exactly as you describe.

clone aqueduct repo.
This is in my pubspec.yaml

dependency_overrides:
  aqueduct:
    path:  C:\src\s\aqueduct\aqueduct
  aqueduct_test:
    path:  C:\src\s\aqueduct\aqueduct_test\

then pub run aqueduct serve:

`PS D:\projects\spur\backend> pub run aqueduct serve
-- Aqueduct CLI Version: 4.0.0-b1
-- Aqueduct project version: 4.0.0-b1
-- Preparing...
data:application/dart;charset=utf-8,import%20'dart%3Aasync'%3B%0Aimport%20'dart%3Aisolate'%3B%0Aimport%20'dart%3Amirrors'%3B%0Aimport%20'package%3Aaqueduct%2Faqueduct.dart'%3B%0Aimport%20'package%3Adart_server%2Fdart_server.dart'%3B%0Aimport%20'package%3Aruntime%2Fruntime.dart'%3B%0AFuture%20main%20(List%3CString%3E%20args%2C%20Map%3CString%2C%20dynamic%3E%20message)%20async%20%7B%0A%20%20final%20sendPort%20%3D%20message%5B'_sendPort'%5D%3B%0A%20%20final%20executable%20%3D%20new%20GetChannelExecutable(message)%3B%0A%20%20final%20result%20%3D%20await%20executable.execute()%3B%0A%20%20sendPort.send(%7B%22_result%22%3A%20result%7D)%3B%0A%7D%0A%20%20%20%20%0Aclass%20GetChannelExecutable%20extends%20Executable%3CString%3E%20%7BGetChannelExecutable(Map%3CString%2C%20dynamic%3E%20message)%20%3A%20super(message)%3B%20%40override%20Future%3CString%3E%20execute()%20async%20%7Bfinal%20channels%20%3D%20RuntimeContext.current.runtimes.iterable.whereType%3CChannelRuntime%3E()%3B%20if%20(channels.length%20!%3D%201)%20%7Bthrow%20StateError(%22No%20ApplicationChannel%20subclass%20was%20found%20for%20this%20project.%20%22%20%22Make%20sure%20it%20is%20imported%20in%20your%20application%20library%20file.%22)%3B%7D%20var%20runtime%20%3D%20channels.first%3B%20if%20(runtime%20%3D%3D%20null)%20%7Breturn%20null%3B%7D%20return%20MirrorSystem.getName(reflectClass(runtime.channelType).simpleName)%3B%7D%20static%20List%3CString%3E%20importsForPackage(String%20packageName)%20%3D%3E%20%5B%22package%3Aaqueduct%2Faqueduct.dart%22%2C%20%22package%3A%24packageName%2F%24packageName.dart%22%2C%20%22package%3Aruntime%2Fruntime.dart%22%5D%3B%7D%0Aabstract%20class%20Executable%3CT%3E%20%7BExecutable(this.message)%20%3A%20_sendPort%20%3D%20message%5B%22_sendPort%22%5D%3B%20Future%3CT%3E%20execute()%3B%20final%20Map%3CString%2C%20dynamic%3E%20message%3B%20final%20SendPort%20_sendPort%3B%20U%20instanceOf%3CU%3E(String%20typeName%2C%20%7BList%20positionalArguments%3A%20const%20%5B%5D%2C%20Map%3CSymbol%2C%20dynamic%3E%20namedArguments%2C%20Symbol%20constructorName%7D)%20%7BClassMirror%20typeMirror%20%3D%20currentMirrorSystem().isolate.rootLibrary.declarations%5Bnew%20Symbol(typeName)%5D%3B%20if%20(typeMirror%20%3D%3D%20null)%20%7BtypeMirror%20%3D%20currentMirrorSystem().libraries.values.where((lib)%20%3D%3E%20lib.uri.scheme%20%3D%3D%20%22package%22%20%7C%7C%20lib.uri.scheme%20%3D%3D%20%22file%22).expand((lib)%20%3D%3E%20lib.declarations.values).firstWhere((decl)%20%3D%3E%20decl%20is%20ClassMirror%20%26%26%20MirrorSystem.getName(decl.simpleName)%20%3D%3D%20typeName%2C%20orElse%3A%20()%20%3D%3E%20throw%20new%20ArgumentError(%22Unknown%20type%20'%24typeName'.%20Did%20you%20forget%20to%20import%20it%3F%22))%3B%7D%20return%20typeMirror.newInstance(constructorName%20%3F%3F%20const%20Symbol(%22%22)%2C%20positionalArguments%2C%20namedArguments).reflectee%20as%20U%3B%7D%20void%20send(dynamic%20message)%20%7B_sendPort.send(message)%3B%7D%20void%20log(String%20message)%20%7B_sendPort.send(%7B%22_line_%22%20%3A%20message%7D)%3B%7D%7D%0A:15:825: Warning: Operand of null-aware operation '??' has type 'Symbol' which excludes null.
 - 'Symbol' is from 'dart:core'.
abstract class Executable<T> {Executable(this.message) : _sendPort = message["_sendPort"]; Future<T> execute(); final Map<String, dynamic> message; final SendPort _sendPort; U instanceOf<U>(String typeName, {List positionalArguments: const [], Map<Symbol, dynamic> namedArguments, Symbol constructorName}) {ClassMirror typeMirror = currentMirrorSystem().isolate.rootLibrary.declarations[new Symbol(typeName)]; if (typeMirror == null) {typeMirror = currentMirrorSystem().libraries.values.where((lib) => lib.uri.scheme == "package" || lib.uri.scheme == "file").expand((lib) => lib.declarations.values).firstWhere((decl) => decl is ClassMirror && MirrorSystem.getName(decl.simpleName) == typeName, orElse: () => throw new ArgumentError("Unknown type '$typeName'. Did you forget to import it?"));} return typeMirror.newInstance(constructorName ?? const Symbol(""), positionalArguments, namedArguments).reflectee as U;} void send(dynamic message) {_sendPort.send(message);} void log(String message) {_sendPort.send({"_line_" : message});}}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ^
*** Uncaught error
    IsolateSpawnException: Unable to spawn isolate: Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:

 - package:aqueduct
 - package:dart_server
 - package:runtime
 - package:logging
 - package:safe_config
 - package:crypto
 - package:password_hash
 - package:open_api
 - package:analyzer
 - package:meta
 - package:pubspec_parse
 - package:yaml
 - package:isolate_executor
 - package:postgres
 - package:path
 - package:watcher
 - package:collection
 - package:convert
 - package:codable
 - package:cli_util
 - package:pub_semver
 - package:_fe_analyzer_shared
 - package:json_annotation
 - package:checked_yaml
 - package:charcode
 - package:source_span
 - package:typed_data
 - package:buffer
 - package:pedantic
 - package:string_scanner
 - package:glob
 - package:args
 - package:async
 - package:term_glyph
 - package:package_config

For solutions, see https://dart.dev/go/unsound-null-safety
data:application/dart;charset=utf-8,import%20'dart%3Aasync'%3B%0Aimport%20'dart%3Aisolate'%3B%0Aimport%20'dart%3Amirrors'%3B%0Aimport%20'package%3Aaqueduct%2Faqueduct.dart'%3B%0Aimport%20'package%3Adart_server%2Fdart_server.dart'%3B%0Aimport%20'package%3Aruntime%2Fruntime.dart'%3B%0AFuture%20main%20(List%3CString%3E%20args%2C%20Map%3CString%2C%20dynamic%3E%20message)%20async%20%7B%0A%20%20final%20sendPort%20%3D%20message%5B'_sendPort'%5D%3B%0A%20%20final%20executable%20%3D%20new%20GetChannelExecutable(message)%3B%0A%20%20final%20result%20%3D%20await%20executable.execute()%3B%0A%20%20sendPort.send(%7B%22_result%22%3A%20result%7D)%3B%0A%7D%0A%20%20%20%20%0Aclass%20GetChannelExecutable%20extends%20Executable%3CString%3E%20%7BGetChannelExecutable(Map%3CString%2C%20dynamic%3E%20message)%20%3A%20super(message)%3B%20%40override%20Future%3CString%3E%20execute()%20async%20%7Bfinal%20channels%20%3D%20RuntimeContext.current.runtimes.iterable.whereType%3CChannelRuntime%3E()%3B%20if%20(channels.length%20!%3D%201)%20%7Bthrow%20StateError(%22No%20ApplicationChannel%20subclass%20was%20found%20for%20this%20project.%20%22%20%22Make%20sure%20it%20is%20imported%20in%20your%20application%20library%20file.%22)%3B%7D%20var%20runtime%20%3D%20channels.first%3B%20if%20(runtime%20%3D%3D%20null)%20%7Breturn%20null%3B%7D%20return%20MirrorSystem.getName(reflectClass(runtime.channelType).simpleName)%3B%7D%20static%20List%3CString%3E%20importsForPackage(String%20packageName)%20%3D%3E%20%5B%22package%3Aaqueduct%2Faqueduct.dart%22%2C%20%22package%3A%24packageName%2F%24packageName.dart%22%2C%20%22package%3Aruntime%2Fruntime.dart%22%5D%3B%7D%0Aabstract%20class%20Executable%3CT%3E%20%7BExecutable(this.message)%20%3A%20_sendPort%20%3D%20message%5B%22_sendPort%22%5D%3B%20Future%3CT%3E%20execute()%3B%20final%20Map%3CString%2C%20dynamic%3E%20message%3B%20final%20SendPort%20_sendPort%3B%20U%20instanceOf%3CU%3E(String%20typeName%2C%20%7BList%20positionalArguments%3A%20const%20%5B%5D%2C%20Map%3CSymbol%2C%20dynamic%3E%20namedArguments%2C%20Symbol%20constructorName%7D)%20%7BClassMirror%20typeMirror%20%3D%20currentMirrorSystem().isolate.rootLibrary.declarations%5Bnew%20Symbol(typeName)%5D%3B%20if%20(typeMirror%20%3D%3D%20null)%20%7BtypeMirror%20%3D%20currentMirrorSystem().libraries.values.where((lib)%20%3D%3E%20lib.uri.scheme%20%3D%3D%20%22package%22%20%7C%7C%20lib.uri.scheme%20%3D%3D%20%22file%22).expand((lib)%20%3D%3E%20lib.declarations.values).firstWhere((decl)%20%3D%3E%20decl%20is%20ClassMirror%20%26%26%20MirrorSystem.getName(decl.simpleName)%20%3D%3D%20typeName%2C%20orElse%3A%20()%20%3D%3E%20throw%20new%20ArgumentError(%22Unknown%20type%20'%24typeName'.%20Did%20you%20forget%20to%20import%20it%3F%22))%3B%7D%20return%20typeMirror.newInstance(constructorName%20%3F%3F%20const%20Symbol(%22%22)%2C%20positionalArguments%2C%20namedArguments).reflectee%20as%20U%3B%7D%20void%20send(dynamic%20message)%20%7B_sendPort.send(message)%3B%7D%20void%20log(String%20message)%20%7B_sendPort.send(%7B%22_line_%22%20%3A%20message%7D)%3B%7D%7D%0A:15:266: Error: The parameter 'namedArguments' can't have a value of 'null' because of its type 'Map<Symbol, dynamic>', but the implicit default value is 'null'.
 - 'Map' is from 'dart:core'.
 - 'Symbol' is from 'dart:core'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
abstract class Executable<T> {Executable(this.message) : _sendPort = message["_sendPort"]; Future<T> execute(); final Map<String, dynamic> message; final SendPort _sendPort; U instanceOf<U>(String typeName, {List positionalArguments: const [], Map<Symbol, dynamic> namedArguments, Symbol constructorName}) {ClassMirror typeMirror = currentMirrorSystem().isolate.rootLibrary.declarations[new Symbol(typeName)]; if (typeMirror == null) {typeMirror = currentMirrorSystem().libraries.values.where((lib) => lib.uri.scheme == "package" || lib.uri.scheme == "file").expand((lib) => lib.declarations.values).firstWhere((decl) => decl is ClassMirror && MirrorSystem.getName(decl.simpleName) == typeName, orElse: () => throw new ArgumentError("Unknown type '$typeName'. Did you forget to import it?"));} return typeMirror.newInstance(constructorName ?? const Symbol(""), positionalArguments, namedArguments).reflectee as U;} void send(dynamic message) {_sendPort.send(message);} void log(String message) {_sendPort.send({"_line_" : message});}}
                                                                                                                                                                                                                                                                         ^^^^^^^^^^^^^^
data:application/dart;charset=utf-8,import%20'dart%3Aasync'%3B%0Aimport%20'dart%3Aisolate'%3B%0Aimport%20'dart%3Amirrors'%3B%0Aimport%20'package%3Aaqueduct%2Faqueduct.dart'%3B%0Aimport%20'package%3Adart_server%2Fdart_server.dart'%3B%0Aimport%20'package%3Aruntime%2Fruntime.dart'%3B%0AFuture%20main%20(List%3CString%3E%20args%2C%20Map%3CString%2C%20dynamic%3E%20message)%20async%20%7B%0A%20%20final%20sendPort%20%3D%20message%5B'_sendPort'%5D%3B%0A%20%20final%20executable%20%3D%20new%20GetChannelExecutable(message)%3B%0A%20%20final%20result%20%3D%20await%20executable.execute()%3B%0A%20%20sendPort.send(%7B%22_result%22%3A%20result%7D)%3B%0A%7D%0A%20%20%20%20%0Aclass%20GetChannelExecutable%20extends%20Executable%3CString%3E%20%7BGetChannelExecutable(Map%3CString%2C%20dynamic%3E%20message)%20%3A%20super(message)%3B%20%40override%20Future%3CString%3E%20execute()%20async%20%7Bfinal%20channels%20%3D%20RuntimeContext.current.runtimes.iterable.whereType%3CChannelRuntime%3E()%3B%20if%20(channels.length%20!%3D%201)%20%7Bthrow%20StateError(%22No%20ApplicationChannel%20subclass%20was%20found%20for%20this%20project.%20%22%20%22Make%20sure%20it%20is%20imported%20in%20your%20application%20library%20file.%22)%3B%7D%20var%20runtime%20%3D%20channels.first%3B%20if%20(runtime%20%3D%3D%20null)%20%7Breturn%20null%3B%7D%20return%20MirrorSystem.getName(reflectClass(runtime.channelType).simpleName)%3B%7D%20static%20List%3CString%3E%20importsForPackage(String%20packageName)%20%3D%3E%20%5B%22package%3Aaqueduct%2Faqueduct.dart%22%2C%20%22package%3A%24packageName%2F%24packageName.dart%22%2C%20%22package%3Aruntime%2Fruntime.dart%22%5D%3B%7D%0Aabstract%20class%20Executable%3CT%3E%20%7BExecutable(this.message)%20%3A%20_sendPort%20%3D%20message%5B%22_sendPort%22%5D%3B%20Future%3CT%3E%20execute()%3B%20final%20Map%3CString%2C%20dynamic%3E%20message%3B%20final%20SendPort%20_sendPort%3B%20U%20instanceOf%3CU%3E(String%20typeName%2C%20%7BList%20positionalArguments%3A%20const%20%5B%5D%2C%20Map%3CSymbol%2C%20dynamic%3E%20namedArguments%2C%20Symbol%20constructorName%7D)%20%7BClassMirror%20typeMirror%20%3D%20currentMirrorSystem().isolate.rootLibrary.declarations%5Bnew%20Symbol(typeName)%5D%3B%20if%20(typeMirror%20%3D%3D%20null)%20%7BtypeMirror%20%3D%20currentMirrorSystem().libraries.values.where((lib)%20%3D%3E%20lib.uri.scheme%20%3D%3D%20%22package%22%20%7C%7C%20lib.uri.scheme%20%3D%3D%20%22file%22).expand((lib)%20%3D%3E%20lib.declarations.values).firstWhere((decl)%20%3D%3E%20decl%20is%20ClassMirror%20%26%26%20MirrorSystem.getName(decl.simpleName)%20%3D%3D%20typeName%2C%20orElse%3A%20()%20%3D%3E%20throw%20new%20ArgumentError(%22Unknown%20type%20'%24typeName'.%20Did%20you%20forget%20to%20import%20it%3F%22))%3B%7D%20return%20typeMirror.newInstance(constructorName%20%3F%3F%20const%20Symbol(%22%22)%2C%20positionalArguments%2C%20namedArguments).reflectee%20as%20U%3B%7D%20void%20send(dynamic%20message)%20%7B_sendPort.send(message)%3B%7D%20void%20log(String%20message)%20%7B_sendPort.send(%7B%22_line_%22%20%3A%20message%7D)%3B%7D%7D%0A:15:289: Error: The parameter 'constructorName' can't have a value of 'null' because of its type 'Symbol', but the implicit default value is 'null'.
 - 'Symbol' is from 'dart:core'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
abstract class Executable<T> {Executable(this.message) : _sendPort = message["_sendPort"]; Future<T> execute(); final Map<String, dynamic> message; final SendPort _sendPort; U instanceOf<U>(String typeName, {List positionalArguments: const [], Map<Symbol, dynamic> namedArguments, Symbol constructorName}) {ClassMirror typeMirror = currentMirrorSystem().isolate.rootLibrary.declarations[new Symbol(typeName)]; if (typeMirror == null) {typeMirror = currentMirrorSystem().libraries.values.where((lib) => lib.uri.scheme == "package" || lib.uri.scheme == "file").expand((lib) => lib.declarations.values).firstWhere((decl) => decl is ClassMirror && MirrorSystem.getName(decl.simpleName) == typeName, orElse: () => throw new ArgumentError("Unknown type '$typeName'. Did you forget to import it?"));} return typeMirror.newInstance(constructorName ?? const Symbol(""), positionalArguments, namedArguments).reflectee as U;} void send(dynamic message) {_sendPort.send(message);} void log(String message) {_sendPort.send({"_line_" : message});}}
                                                                                                                                                                                                                                                                                                ^^^^^^^^^^^^^^^
data:application/dart;charset=utf-8,import%20'dart%3Aasync'%3B%0Aimport%20'dart%3Aisolate'%3B%0Aimport%20'dart%3Amirrors'%3B%0Aimport%20'package%3Aaqueduct%2Faqueduct.dart'%3B%0Aimport%20'package%3Adart_server%2Fdart_server.dart'%3B%0Aimport%20'package%3Aruntime%2Fruntime.dart'%3B%0AFuture%20main%20(List%3CString%3E%20args%2C%20Map%3CString%2C%20dynamic%3E%20message)%20async%20%7B%0A%20%20final%20sendPort%20%3D%20message%5B'_sendPort'%5D%3B%0A%20%20final%20executable%20%3D%20new%20GetChannelExecutable(message)%3B%0A%20%20final%20result%20%3D%20await%20executable.execute()%3B%0A%20%20sendPort.send(%7B%22_result%22%3A%20result%7D)%3B%0A%7D%0A%20%20%20%20%0Aclass%20GetChannelExecutable%20extends%20Executable%3CString%3E%20%7BGetChannelExecutable(Map%3CString%2C%20dynamic%3E%20message)%20%3A%20super(message)%3B%20%40override%20Future%3CString%3E%20execute()%20async%20%7Bfinal%20channels%20%3D%20RuntimeContext.current.runtimes.iterable.whereType%3CChannelRuntime%3E()%3B%20if%20(channels.length%20!%3D%201)%20%7Bthrow%20StateError(%22No%20ApplicationChannel%20subclass%20was%20found%20for%20this%20project.%20%22%20%22Make%20sure%20it%20is%20imported%20in%20your%20application%20library%20file.%22)%3B%7D%20var%20runtime%20%3D%20channels.first%3B%20if%20(runtime%20%3D%3D%20null)%20%7Breturn%20null%3B%7D%20return%20MirrorSystem.getName(reflectClass(runtime.channelType).simpleName)%3B%7D%20static%20List%3CString%3E%20importsForPackage(String%20packageName)%20%3D%3E%20%5B%22package%3Aaqueduct%2Faqueduct.dart%22%2C%20%22package%3A%24packageName%2F%24packageName.dart%22%2C%20%22package%3Aruntime%2Fruntime.dart%22%5D%3B%7D%0Aabstract%20class%20Executable%3CT%3E%20%7BExecutable(this.message)%20%3A%20_sendPort%20%3D%20message%5B%22_sendPort%22%5D%3B%20Future%3CT%3E%20execute()%3B%20final%20Map%3CString%2C%20dynamic%3E%20message%3B%20final%20SendPort%20_sendPort%3B%20U%20instanceOf%3CU%3E(String%20typeName%2C%20%7BList%20positionalArguments%3A%20const%20%5B%5D%2C%20Map%3CSymbol%2C%20dynamic%3E%20namedArguments%2C%20Symbol%20constructorName%7D)%20%7BClassMirror%20typeMirror%20%3D%20currentMirrorSystem().isolate.rootLibrary.declarations%5Bnew%20Symbol(typeName)%5D%3B%20if%20(typeMirror%20%3D%3D%20null)%20%7BtypeMirror%20%3D%20currentMirrorSystem().libraries.values.where((lib)%20%3D%3E%20lib.uri.scheme%20%3D%3D%20%22package%22%20%7C%7C%20lib.uri.scheme%20%3D%3D%20%22file%22).expand((lib)%20%3D%3E%20lib.declarations.values).firstWhere((decl)%20%3D%3E%20decl%20is%20ClassMirror%20%26%26%20MirrorSystem.getName(decl.simpleName)%20%3D%3D%20typeName%2C%20orElse%3A%20()%20%3D%3E%20throw%20new%20ArgumentError(%22Unknown%20type%20'%24typeName'.%20Did%20you%20forget%20to%20import%20it%3F%22))%3B%7D%20return%20typeMirror.newInstance(constructorName%20%3F%3F%20const%20Symbol(%22%22)%2C%20positionalArguments%2C%20namedArguments).reflectee%20as%20U%3B%7D%20void%20send(dynamic%20message)%20%7B_sendPort.send(message)%3B%7D%20void%20log(String%20message)%20%7B_sendPort.send(%7B%22_line_%22%20%3A%20message%7D)%3B%7D%7D%0A:14:483: Error: The value 'null' can't be returned from an async function with return type 'Future<String>' because 'Future<String>' is not nullable.
 - 'Future' is from 'dart:async'.
class GetChannelExecutable extends Executable<String> {GetChannelExecutable(Map<String, dynamic> message) : super(message); @override Future<String> execute() async {final channels = RuntimeContext.current.runtimes.iterable.whereType<ChannelRuntime>(); if (channels.length != 1) {throw StateError("No ApplicationChannel subclass was found for this project. " "Make sure it is imported in your application library file.");} var runtime = channels.first; if (runtime == null) {return null;} return MirrorSystem.getName(reflectClass(runtime.channelType).simpleName);} static List<String> importsForPackage(String packageName) => ["package:aqueduct/aqueduct.dart", "package:$packageName/$packageName.dart", "package:runtime/runtime.dart"];}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ^
data:application/dart;charset=utf-8,import%20'dart%3Aasync'%3B%0Aimport%20'dart%3Aisolate'%3B%0Aimport%20'dart%3Amirrors'%3B%0Aimport%20'package%3Aaqueduct%2Faqueduct.dart'%3B%0Aimport%20'package%3Adart_server%2Fdart_server.dart'%3B%0Aimport%20'package%3Aruntime%2Fruntime.dart'%3B%0AFuture%20main%20(List%3CString%3E%20args%2C%20Map%3CString%2C%20dynamic%3E%20message)%20async%20%7B%0A%20%20final%20sendPort%20%3D%20message%5B'_sendPort'%5D%3B%0A%20%20final%20executable%20%3D%20new%20GetChannelExecutable(message)%3B%0A%20%20final%20result%20%3D%20await%20executable.execute()%3B%0A%20%20sendPort.send(%7B%22_result%22%3A%20result%7D)%3B%0A%7D%0A%20%20%20%20%0Aclass%20GetChannelExecutable%20extends%20Executable%3CString%3E%20%7BGetChannelExecutable(Map%3CString%2C%20dynamic%3E%20message)%20%3A%20super(message)%3B%20%40override%20Future%3CString%3E%20execute()%20async%20%7Bfinal%20channels%20%3D%20RuntimeContext.current.runtimes.iterable.whereType%3CChannelRuntime%3E()%3B%20if%20(channels.length%20!%3D%201)%20%7Bthrow%20StateError(%22No%20ApplicationChannel%20subclass%20was%20found%20for%20this%20project.%20%22%20%22Make%20sure%20it%20is%20imported%20in%20your%20application%20library%20file.%22)%3B%7D%20var%20runtime%20%3D%20channels.first%3B%20if%20(runtime%20%3D%3D%20null)%20%7Breturn%20null%3B%7D%20return%20MirrorSystem.getName(reflectClass(runtime.channelType).simpleName)%3B%7D%20static%20List%3CString%3E%20importsForPackage(String%20packageName)%20%3D%3E%20%5B%22package%3Aaqueduct%2Faqueduct.dart%22%2C%20%22package%3A%24packageName%2F%24packageName.dart%22%2C%20%22package%3Aruntime%2Fruntime.dart%22%5D%3B%7D%0Aabstract%20class%20Executable%3CT%3E%20%7BExecutable(this.message)%20%3A%20_sendPort%20%3D%20message%5B%22_sendPort%22%5D%3B%20Future%3CT%3E%20execute()%3B%20final%20Map%3CString%2C%20dynamic%3E%20message%3B%20final%20SendPort%20_sendPort%3B%20U%20instanceOf%3CU%3E(String%20typeName%2C%20%7BList%20positionalArguments%3A%20const%20%5B%5D%2C%20Map%3CSymbol%2C%20dynamic%3E%20namedArguments%2C%20Symbol%20constructorName%7D)%20%7BClassMirror%20typeMirror%20%3D%20currentMirrorSystem().isolate.rootLibrary.declarations%5Bnew%20Symbol(typeName)%5D%3B%20if%20(typeMirror%20%3D%3D%20null)%20%7BtypeMirror%20%3D%20currentMirrorSystem().libraries.values.where((lib)%20%3D%3E%20lib.uri.scheme%20%3D%3D%20%22package%22%20%7C%7C%20lib.uri.scheme%20%3D%3D%20%22file%22).expand((lib)%20%3D%3E%20lib.declarations.values).firstWhere((decl)%20%3D%3E%20decl%20is%20ClassMirror%20%26%26%20MirrorSystem.getName(decl.simpleName)%20%3D%3D%20typeName%2C%20orElse%3A%20()%20%3D%3E%20throw%20new%20ArgumentError(%22Unknown%20type%20'%24typeName'.%20Did%20you%20forget%20to%20import%20it%3F%22))%3B%7D%20return%20typeMirror.newInstance(constructorName%20%3F%3F%20const%20Symbol(%22%22)%2C%20positionalArguments%2C%20namedArguments).reflectee%20as%20U%3B%7D%20void%20send(dynamic%20message)%20%7B_sendPort.send(message)%3B%7D%20void%20log(String%20message)%20%7B_sendPort.send(%7B%22_line_%22%20%3A%20message%7D)%3B%7D%7D%0A:15:387: Error: A value of type 'DeclarationMirror?' can't be assigned to a variable of type 'ClassMirror'.
 - 'DeclarationMirror' is from 'dart:mirrors'.
 - 'ClassMirror' is from 'dart:mirrors'.
abstract class Executable<T> {Executable(this.message) : _sendPort = message["_sendPort"]; Future<T> execute(); final Map<String, dynamic> message; final SendPort _sendPort; U instanceOf<U>(String typeName, {List positionalArguments: const [], Map<Symbol, dynamic> namedArguments, Symbol constructorName}) {ClassMirror typeMirror = currentMirrorSystem().isolate.rootLibrary.declarations[new Symbol(typeName)]; if (typeMirror == null) {typeMirror = currentMirrorSystem().libraries.values.where((lib) => lib.uri.scheme == "package" || lib.uri.scheme == "file").expand((lib) => lib.declarations.values).firstWhere((decl) => decl is ClassMirror && MirrorSystem.getName(decl.simpleName) == typeName, orElse: () => throw new ArgumentError("Unknown type '$typeName'. Did you forget to import it?"));} return typeMirror.newInstance(constructorName ?? const Symbol(""), positionalArguments, namedArguments).reflectee as U;} void send(dynamic message) {_sendPort.send(message);} void log(String message) {_sendPort.send({"_line_" : message});}}
                                                                                                                                                                                                                                                                                                                                                                                                  ^
data:application/dart;charset=utf-8,import%20'dart%3Aasync'%3B%0Aimport%20'dart%3Aisolate'%3B%0Aimport%20'dart%3Amirrors'%3B%0Aimport%20'package%3Aaqueduct%2Faqueduct.dart'%3B%0Aimport%20'package%3Adart_server%2Fdart_server.dart'%3B%0Aimport%20'package%3Aruntime%2Fruntime.dart'%3B%0AFuture%20main%20(List%3CString%3E%20args%2C%20Map%3CString%2C%20dynamic%3E%20message)%20async%20%7B%0A%20%20final%20sendPort%20%3D%20message%5B'_sendPort'%5D%3B%0A%20%20final%20executable%20%3D%20new%20GetChannelExecutable(message)%3B%0A%20%20final%20result%20%3D%20await%20executable.execute()%3B%0A%20%20sendPort.send(%7B%22_result%22%3A%20result%7D)%3B%0A%7D%0A%20%20%20%20%0Aclass%20GetChannelExecutable%20extends%20Executable%3CString%3E%20%7BGetChannelExecutable(Map%3CString%2C%20dynamic%3E%20message)%20%3A%20super(message)%3B%20%40override%20Future%3CString%3E%20execute()%20async%20%7Bfinal%20channels%20%3D%20RuntimeContext.current.runtimes.iterable.whereType%3CChannelRuntime%3E()%3B%20if%20(channels.length%20!%3D%201)%20%7Bthrow%20StateError(%22No%20ApplicationChannel%20subclass%20was%20found%20for%20this%20project.%20%22%20%22Make%20sure%20it%20is%20imported%20in%20your%20application%20library%20file.%22)%3B%7D%20var%20runtime%20%3D%20channels.first%3B%20if%20(runtime%20%3D%3D%20null)%20%7Breturn%20null%3B%7D%20return%20MirrorSystem.getName(reflectClass(runtime.channelType).simpleName)%3B%7D%20static%20List%3CString%3E%20importsForPackage(String%20packageName)%20%3D%3E%20%5B%22package%3Aaqueduct%2Faqueduct.dart%22%2C%20%22package%3A%24packageName%2F%24packageName.dart%22%2C%20%22package%3Aruntime%2Fruntime.dart%22%5D%3B%7D%0Aabstract%20class%20Executable%3CT%3E%20%7BExecutable(this.message)%20%3A%20_sendPort%20%3D%20message%5B%22_sendPort%22%5D%3B%20Future%3CT%3E%20execute()%3B%20final%20Map%3CString%2C%20dynamic%3E%20message%3B%20final%20SendPort%20_sendPort%3B%20U%20instanceOf%3CU%3E(String%20typeName%2C%20%7BList%20positionalArguments%3A%20const%20%5B%5D%2C%20Map%3CSymbol%2C%20dynamic%3E%20namedArguments%2C%20Symbol%20constructorName%7D)%20%7BClassMirror%20typeMirror%20%3D%20currentMirrorSystem().isolate.rootLibrary.declarations%5Bnew%20Symbol(typeName)%5D%3B%20if%20(typeMirror%20%3D%3D%20null)%20%7BtypeMirror%20%3D%20currentMirrorSystem().libraries.values.where((lib)%20%3D%3E%20lib.uri.scheme%20%3D%3D%20%22package%22%20%7C%7C%20lib.uri.scheme%20%3D%3D%20%22file%22).expand((lib)%20%3D%3E%20lib.declarations.values).firstWhere((decl)%20%3D%3E%20decl%20is%20ClassMirror%20%26%26%20MirrorSystem.getName(decl.simpleName)%20%3D%3D%20typeName%2C%20orElse%3A%20()%20%3D%3E%20throw%20new%20ArgumentError(%22Unknown%20type%20'%24typeName'.%20Did%20you%20forget%20to%20import%20it%3F%22))%3B%7D%20return%20typeMirror.newInstance(constructorName%20%3F%3F%20const%20Symbol(%22%22)%2C%20positionalArguments%2C%20namedArguments).reflectee%20as%20U%3B%7D%20void%20send(dynamic%20message)%20%7B_sendPort.send(message)%3B%7D%20void%20log(String%20message)%20%7B_sendPort.send(%7B%22_line_%22%20%3A%20message%7D)%3B%7D%7D%0A:15:601: Error: A value of type 'DeclarationMirror' can't be assigned to a variable of type 'ClassMirror'.
 - 'DeclarationMirror' is from 'dart:mirrors'.
 - 'ClassMirror' is from 'dart:mirrors'.
abstract class Executable<T> {Executable(this.message) : _sendPort = message["_sendPort"]; Future<T> execute(); final Map<String, dynamic> message; final SendPort _sendPort; U instanceOf<U>(String typeName, {List positionalArguments: const [], Map<Symbol, dynamic> namedArguments, Symbol constructorName}) {ClassMirror typeMirror = currentMirrorSystem().isolate.rootLibrary.declarations[new Symbol(typeName)]; if (typeMirror == null) {typeMirror = currentMirrorSystem().libraries.values.where((lib) => lib.uri.scheme == "package" || lib.uri.scheme == "file").expand((lib) => lib.declarations.values).firstWhere((decl) => decl is ClassMirror && MirrorSystem.getName(decl.simpleName) == typeName, orElse: () => throw new ArgumentError("Unknown type '$typeName'. Did you forget to import it?"));} return typeMirror.newInstance(constructorName ?? const Symbol(""), positionalArguments, namedArguments).reflectee as U;} void send(dynamic message) {_sendPort.send(message);} void log(String message) {_sendPort.send({"_line_" : message});}}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ^
  **** Stacktrace
  ****
PS D:\projects\spur\backend>`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants