2
votes

I get this error when searching for results. Spent hours now to debug, but can't discover what the issue might be. Must be some deserialisation issue, when trying to assign the id to the Place object. But I'm no JavaScript expert (thats why I want to use dart). But of course the files are converted into JavaScript, and the Developer Tools debugger then references to the generated JS files.

The strange thing is that it was working with my mock backend. But it's not working with the Aqueduct backend. Aqueduct itself is providing the right output.

[{"id":1,"name":"Easyhotel"},{"id":2,"name":"Hotel Greulich"}]

Fetching a list of all objects is working. Seems only to be related to the search method.

Any hint would be appreciated.

Version

Dart VM version: 2.0.0-dev.68.0 (Tue Jul 10 14:47:26 2018 +0200) on "macos_x64"

pubspec.yaml

name: places
description: Cool Places
version: 0.0.1

environment:
  sdk: '>=2.0.0-dev.66.0 <2.0.0'

dependencies:
  angular: ^5.0.0-beta
  angular_forms: ^2.0.0-beta
  angular_router: ^2.0.0-alpha
  http: ^0.11.0            
  stream_transform: ^0.0.6
  angular_components: ^0.9.0-alpha+15

dev_dependencies:
  sass_builder: ^2.0.0
  angular_test: ^2.0.0-beta
  build_runner: ^0.9.0
  build_test: ^0.10.2
  build_web_compilers: ^0.4.0
  test: ^1.0.0

place_search_service.dart

import 'dart:async';
import 'dart:convert';
import 'package:angular/angular.dart';
import 'package:http/http.dart';

import 'package:places/src/place/place.dart';

@Injectable()
class PlaceSearchService {
  final Client _http;

  PlaceSearchService(this._http);

  Future<List<Place>> search(String term) async {
    try {
      final response = await _http.get('http://localhost:8888/places?name=$term');
      return (_extractData(response) as List)
          .map((json) => new Place.fromJson(json))
          .toList();
    } catch (e) {
      throw _handleError(e);
    }
  }

  dynamic _extractData(Response resp) => json.decode(resp.body)['data'];

  Exception _handleError(dynamic e) {
    print(e); // for demo purposes only
    return new Exception('Server error; cause: $e');
  }
}

place.dart

class Place {
  final int id;
  String name;

  Place(this.id, this.name);

  factory Place.fromJson(Map<String, dynamic> place) =>
      new Place(_toInt(place['id']), place['name']);
  Map toJson() => {'id': id, 'name': name};
}

int _toInt(id) => id is int ? id : int.parse(id);

Stacktrace from Chrome Dev Tools

`dart_sdk.js:101652 EXCEPTION: Exception: Server error; cause: Type 'String' is not a subtype of expected type 'int'. STACKTRACE: packages/$sdk/dev_compiler/amd/dart_sdk.js 4835:29 throw packages/places/src/place/place_search_service.ddc.js 28:21 search packages/$sdk/dev_compiler/amd/dart_sdk.js 23385:33 onValue packages/stack_trace/stack_trace.ddc.js 142:98 .dart.fn packages/stack_trace/stack_trace.ddc.js 188:16 [_run] packages/stack_trace/stack_trace.ddc.js 142:80 arg packages/angular/src/core/zone/ng_zone.ddc.js 117:18 arg packages/$sdk/dev_compiler/amd/dart_sdk.js 29365:56 _rootRunUnary packages/$sdk/dev_compiler/amd/dart_sdk.js 28991:14 runUnary packages/angular/src/core/zone/ng_zone.ddc.js 114:21 [_runUnary] packages/$sdk/dev_compiler/amd/dart_sdk.js 29193:14 runUnary packages/$sdk/dev_compiler/amd/dart_sdk.js 25288:29 handleValue packages/$sdk/dev_compiler/amd/dart_sdk.js 25750:49 handleValueCallback packages/$sdk/dev_compiler/amd/dart_sdk.js 25780:17 _propagateToListeners packages/$sdk/dev_compiler/amd/dart_sdk.js 25643:23 [_completeWithValue] packages/$sdk/dev_compiler/amd/dart_sdk.js 25661:35 .scheduleMicrotask.dart.fn packages/angular/src/core/zone/ng_zone.ddc.js 92:11 safeMicrotask packages/stack_trace/stack_trace.ddc.js 188:16 [_run] packages/stack_trace/stack_trace.ddc.js 137:71 parent.registerCallback.dart.fn packages/angular/src/core/zone/ng_zone.ddc.js 107:18 parent.run.dart.fn packages/$sdk/dev_compiler/amd/dart_sdk.js 29359:14 _rootRun packages/$sdk/dev_compiler/amd/dart_sdk.js 28985:14 run packages/angular/src/core/zone/ng_zone.ddc.js 104:21 [_run] packages/$sdk/dev_compiler/amd/dart_sdk.js 29186:14 run packages/$sdk/dev_compiler/amd/dart_sdk.js 29106:14 runGuarded packages/$sdk/dev_compiler/amd/dart_sdk.js 29142:33 async._AsyncCallbackEntry.new.dart.fn packages/$sdk/dev_compiler/amd/dart_sdk.js 25990:13 _microtaskLoop packages/$sdk/dev_compiler/amd/dart_sdk.js 25996:13 _startMicrotaskLoop packages/$sdk/dev_compiler/amd/dart_sdk.js 26066:11 internalCallback

packages/$sdk/dev_compiler/amd/dart_sdk.js 29214:14 registerUnaryCallback packages/$sdk/dev_compiler/amd/dart_sdk.js 23396:22 async packages/places/src/place/place_search_service.ddc.js 23:20 search packages/places/src/place/place_list_component.ddc.js 69:58 search packages/$sdk/dev_compiler/amd/dart_sdk.js 23404:34 runBody packages/$sdk/dev_compiler/amd/dart_sdk.js 23431:7 async packages/places/src/place/place_list_component.ddc.js 65:20 search packages/places/src/place/place_list_component.template.ddc.js 158:16 [_handle_click_15_0] packages/angular/src/bootstrap/modules.ddc.js 1869:106 src__core__linker__app_view_utils.appViewUtils.eventManager.getZone.runGuarded.dart.fn packages/angular/src/core/zone/ng_zone.ddc.js 107:18 parent.run.dart.fn packages/$sdk/dev_compiler/amd/dart_sdk.js 29359:14 _rootRun packages/$sdk/dev_compiler/amd/dart_sdk.js 28985:14 run packages/angular/src/core/zone/ng_zone.ddc.js 104:21 [_run] packages/$sdk/dev_compiler/amd/dart_sdk.js 29186:14 run packages/$sdk/dev_compiler/amd/dart_sdk.js 29106:14 runGuarded packages/angular/src/core/zone/ng_zone.ddc.js 223:31 runGuarded packages/angular/src/bootstrap/modules.ddc.js 1869:81 event`

When examining the error object by setting a breakpoint

Symbol(_error) : Error at Object.dart.throw (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:4835:29) at Object.dart.castError (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:4462:15) at Object.dart.as (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:4751:17) at Function.check_int [as _check] (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:9997:17) at Object.dart._checkApply (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:4572:19) at Object.dart._checkAndCall (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:4653:14) at Object.dart.callMethod (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:4702:17) at Object.dart.dindex (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:4717:17) at src__place__place_search_service.PlaceSearchService.new.[_extractData] (http://localhost:8080/packages/places/src/place/place_search_service.ddc.js:33:19) at src__place__place_search_service.PlaceSearchService.new.search (http://localhost:8080/packages/places/src/place/place_search_service.ddc.js:26:49) at search.next (<anonymous>) at onValue (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:23385:33) at (anonymous function).dart.fn (http://localhost:8080/packages/stack_trace/stack_trace.ddc.js:142:98) at src__stack_zone_specification.StackZoneSpecification.new.[_run] (http://localhost:8080/packages/stack_trace/stack_trace.ddc.js:188:16) at parent.registerUnaryCallback.dart.fn.arg (http://localhost:8080/packages/stack_trace/stack_trace.ddc.js:142:80) at parent.runUnary.dart.fn.arg (http://localhost:8080/packages/angular/src/core/zone/ng_zone.ddc.js:117:18) at async._rootRunUnary (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:29365:56) at async._ZoneDelegate.new.runUnary (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:28991:14) at src__core__zone__ng_zone.NgZone.new.[_runUnary] (http://localhost:8080/packages/angular/src/core/zone/ng_zone.ddc.js:114:21) at async._CustomZone.new.runUnary (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:29193:14) at _FutureListener.then.handleValue (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:25288:29) at handleValueCallback (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:25750:49) at Function._propagateToListeners (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:25780:17) at _Future.new.[_completeWithValue] (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:25643:23) at (anonymous function).scheduleMicrotask.dart.fn (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:25661:35) at safeMicrotask (http://localhost:8080/packages/angular/src/core/zone/ng_zone.ddc.js:92:11) at src__stack_zone_specification.StackZoneSpecification.new.[_run] (http://localhost:8080/packages/stack_trace/stack_trace.ddc.js:188:16) at parent.registerCallback.dart.fn (http://localhost:8080/packages/stack_trace/stack_trace.ddc.js:137:71) at parent.run.dart.fn (http://localhost:8080/packages/angular/src/core/zone/ng_zone.ddc.js:107:18) at async._rootRun (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:29359:14) at async._ZoneDelegate.new.run (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:28985:14) at src__core__zone__ng_zone.NgZone.new.[_run] (http://localhost:8080/packages/angular/src/core/zone/ng_zone.ddc.js:104:21) at async._CustomZone.new.run (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:29186:14) at async._CustomZone.new.runGuarded (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:29106:14) at async._AsyncCallbackEntry.new.dart.fn [as callback] (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:29142:33) at Object.async._microtaskLoop (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:25990:13) at async._startMicrotaskLoop (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:25996:13) at MutationObserver.internalCallback (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:26066:11) stack : "Error↵ at Object.dart.throw (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:4835:29)↵ at Object.dart.castError (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:4462:15)↵ at Object.dart.as (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:4751:17)↵ at Function.check_int [as _check] (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:9997:17)↵ at Object.dart._checkApply (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:4572:19)↵ at Object.dart._checkAndCall (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:4653:14)↵ at Object.dart.callMethod (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:4702:17)↵ at Object.dart.dindex (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:4717:17)↵ at src__place__place_search_service.PlaceSearchService.new.[_extractData] (http://localhost:8080/packages/places/src/place/place_search_service.ddc.js:33:19)↵ at src__place__place_search_service.PlaceSearchService.new.search (http://localhost:8080/packages/places/src/place/place_search_service.ddc.js:26:49)↵ at search.next (<anonymous>)↵ at onValue (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:23385:33)↵ at (anonymous function).dart.fn (http://localhost:8080/packages/stack_trace/stack_trace.ddc.js:142:98)↵ at src__stack_zone_specification.StackZoneSpecification.new.[_run] (http://localhost:8080/packages/stack_trace/stack_trace.ddc.js:188:16)↵ at parent.registerUnaryCallback.dart.fn.arg (http://localhost:8080/packages/stack_trace/stack_trace.ddc.js:142:80)↵ at parent.runUnary.dart.fn.arg (http://localhost:8080/packages/angular/src/core/zone/ng_zone.ddc.js:117:18)↵ at async._rootRunUnary (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:29365:56)↵ at async._ZoneDelegate.new.runUnary (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:28991:14)↵ at src__core__zone__ng_zone.NgZone.new.[_runUnary] (http://localhost:8080/packages/angular/src/core/zone/ng_zone.ddc.js:114:21)↵ at async._CustomZone.new.runUnary (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:29193:14)↵ at _FutureListener.then.handleValue (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:25288:29)↵ at handleValueCallback (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:25750:49)↵ at Function._propagateToListeners (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:25780:17)↵ at _Future.new.[_completeWithValue] (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:25643:23)↵ at (anonymous function).scheduleMicrotask.dart.fn (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:25661:35)↵ at safeMicrotask (http://localhost:8080/packages/angular/src/core/zone/ng_zone.ddc.js:92:11)↵ at src__stack_zone_specification.StackZoneSpecification.new.[_run] (http://localhost:8080/packages/stack_trace/stack_trace.ddc.js:188:16)↵ at parent.registerCallback.dart.fn (http://localhost:8080/packages/stack_trace/stack_trace.ddc.js:137:71)↵ at parent.run.dart.fn (http://localhost:8080/packages/angular/src/core/zone/ng_zone.ddc.js:107:18)↵ at async._rootRun (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:29359:14)↵ at async._ZoneDelegate.new.run (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:28985:14)↵ at src__core__zone__ng_zone.NgZone.new.[_run] (http://localhost:8080/packages/angular/src/core/zone/ng_zone.ddc.js:104:21)↵ at async._CustomZone.new.run (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:29186:14)↵ at async._CustomZone.new.runGuarded (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:29106:14)↵ at async._AsyncCallbackEntry.new.dart.fn [as callback] (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:29142:33)↵ at Object.async._microtaskLoop (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:25990:13)↵ at async._startMicrotaskLoop (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:25996:13)↵ at MutationObserver.internalCallback (http://localhost:8080/packages/$sdk/dev_compiler/amd/dart_sdk.js:26066:11)"

With commented out throw _handleError

`dart_sdk.js:101652 EXCEPTION: TypeError: Cannot read property 'Symbol(dartx.length)' of undefined STACKTRACE: packages/places/src/place/place_list_component.ddc.js 71:24 search packages/$sdk/dev_compiler/amd/dart_sdk.js 23385:33 onValue packages/stack_trace/stack_trace.ddc.js 142:98 .dart.fn packages/stack_trace/stack_trace.ddc.js 188:16 [_run] packages/stack_trace/stack_trace.ddc.js 142:80 arg packages/angular/src/core/zone/ng_zone.ddc.js 117:18 arg packages/$sdk/dev_compiler/amd/dart_sdk.js 29365:56 _rootRunUnary packages/$sdk/dev_compiler/amd/dart_sdk.js 28991:14 runUnary packages/angular/src/core/zone/ng_zone.ddc.js 114:21 [_runUnary] packages/$sdk/dev_compiler/amd/dart_sdk.js 29193:14 runUnary packages/$sdk/dev_compiler/amd/dart_sdk.js 25288:29 handleValue packages/$sdk/dev_compiler/amd/dart_sdk.js 25750:49 handleValueCallback packages/$sdk/dev_compiler/amd/dart_sdk.js 25780:17 _propagateToListeners packages/$sdk/dev_compiler/amd/dart_sdk.js 25643:23 [_completeWithValue] packages/$sdk/dev_compiler/amd/dart_sdk.js 25661:35 .scheduleMicrotask.dart.fn packages/angular/src/core/zone/ng_zone.ddc.js 92:11 safeMicrotask packages/stack_trace/stack_trace.ddc.js 188:16 [_run] packages/stack_trace/stack_trace.ddc.js 137:71 parent.registerCallback.dart.fn packages/angular/src/core/zone/ng_zone.ddc.js 107:18 parent.run.dart.fn packages/$sdk/dev_compiler/amd/dart_sdk.js 29359:14 _rootRun packages/$sdk/dev_compiler/amd/dart_sdk.js 28985:14 run packages/angular/src/core/zone/ng_zone.ddc.js 104:21 [_run] packages/$sdk/dev_compiler/amd/dart_sdk.js 29186:14 run packages/$sdk/dev_compiler/amd/dart_sdk.js 29106:14 runGuarded packages/$sdk/dev_compiler/amd/dart_sdk.js 29142:33 async._AsyncCallbackEntry.new.dart.fn packages/$sdk/dev_compiler/amd/dart_sdk.js 25990:13 _microtaskLoop packages/$sdk/dev_compiler/amd/dart_sdk.js 25996:13 _startMicrotaskLoop packages/$sdk/dev_compiler/amd/dart_sdk.js 26066:11 internalCallback

packages/$sdk/dev_compiler/amd/dart_sdk.js 29214:14 registerUnaryCallback packages/$sdk/dev_compiler/amd/dart_sdk.js 23396:22 async packages/places/src/place/place_list_component.ddc.js 65:20 search packages/places/src/place/place_list_component.template.ddc.js 158:16 [_handle_click_15_0] packages/angular/src/bootstrap/modules.ddc.js 1869:106 src__core__linker__app_view_utils.appViewUtils.eventManager.getZone.runGuarded.dart.fn packages/angular/src/core/zone/ng_zone.ddc.js 107:18 parent.run.dart.fn packages/$sdk/dev_compiler/amd/dart_sdk.js 29359:14 _rootRun packages/$sdk/dev_compiler/amd/dart_sdk.js 28985:14 run packages/angular/src/core/zone/ng_zone.ddc.js 104:21 [_run] packages/$sdk/dev_compiler/amd/dart_sdk.js 29186:14 run packages/$sdk/dev_compiler/amd/dart_sdk.js 29106:14 runGuarded packages/angular/src/core/zone/ng_zone.ddc.js 223:31 runGuarded packages/angular/src/bootstrap/modules.ddc.js 1869:81 event

error @ dart_sdk.js:101652 handle @ exceptions.dart:14 call @ exceptions.dart:11 handleUncaughtException @ application_ref.dart:134 (anonymous function).(anonymous function).(anonymous function).onError.listen.dart.fn.error @ application_ref.dart:51 (anonymous function).dart.fn @ stack_zone_specification.dart:129 [_run] @ stack_zone_specification.dart:209 parent.registerUnaryCallback.dart.fn.arg @ stack_zone_specification.dart:129 parent.runUnary.dart.fn.arg @ ng_zone.dart:190 async._rootRunUnary @ dart_sdk.js:29368 runUnary @ dart_sdk.js:28991 [_runUnary] @ ng_zone.dart:187 runUnary @ dart_sdk.js:29193 runUnaryGuarded @ dart_sdk.js:29114 [_sendData] @ dart_sdk.js:23973 [_add] @ dart_sdk.js:23920 [_sendData] @ dart_sdk.js:24605 add @ dart_sdk.js:24415 [_onErrorWithLongStackTrace] @ ng_zone.dart:228 async._rootRunBinary @ dart_sdk.js:29377 runBinary @ dart_sdk.js:29579 [_handleUncaughtError] @ stack_zone_specification.dart:163 handleUncaughtError @ dart_sdk.js:29170 _propagateToListeners @ dart_sdk.js:25693 [_completeWithValue] @ dart_sdk.js:25643 (anonymous function).scheduleMicrotask.dart.fn @ dart_sdk.js:25661 safeMicrotask @ ng_zone.dart:163 [_run] @ stack_zone_specification.dart:209 parent.registerCallback.dart.fn @ stack_zone_specification.dart:119 parent.run.dart.fn @ ng_zone.dart:178 async._rootRun @ dart_sdk.js:29359 run @ dart_sdk.js:28985 [_run] @ ng_zone.dart:175 run @ dart_sdk.js:29186 runGuarded @ dart_sdk.js:29106 dart.fn @ dart_sdk.js:29142 async._microtaskLoop @ dart_sdk.js:25990 async._startMicrotaskLoop @ dart_sdk.js:25996 internalCallback @ dart_sdk.js:26066 childList (async)
dart.fn.callback @ dart_sdk.js:26076 _scheduleImmediate @ dart_sdk.js:26052 async._scheduleAsyncCallback @ dart_sdk.js:26010 async._rootScheduleMicrotask @ dart_sdk.js:29404 scheduleMicrotask @ dart_sdk.js:29028 [_scheduleMicrotask] @ ng_zone.dart:171 scheduleMicrotask @ dart_sdk.js:29237 [_asyncComplete] @ dart_sdk.js:25660 complete @ dart_sdk.js:25194 reader.(anonymous function).first.then.dart.fn._ @ browser_client.dart:60 (anonymous function).dart.fn @ stack_zone_specification.dart:129 [_run] @ stack_zone_specification.dart:209 parent.registerUnaryCallback.dart.fn.arg @ stack_zone_specification.dart:129 parent.runUnary.dart.fn.arg @ ng_zone.dart:190 async._rootRunUnary @ dart_sdk.js:29365 runUnary @ dart_sdk.js:28991 [_runUnary] @ ng_zone.dart:187 runUnary @ dart_sdk.js:29193 handleValue @ dart_sdk.js:25288 handleValueCallback @ dart_sdk.js:25750 _propagateToListeners @ dart_sdk.js:25780 [_complete] @ dart_sdk.js:25634 async._cancelAndValue @ dart_sdk.js:27687 subscription.listen.dart.fn.value @ dart_sdk.js:10492 dart._checkAndCall @ dart_sdk.js:4656 dart.dcall @ dart_sdk.js:4661 (anonymous function).html$._wrapZone.dart.fn.e @ dart_sdk.js:99172 (anonymous function).dart.fn @ stack_zone_specification.dart:129 [_run] @ stack_zone_specification.dart:209 parent.registerUnaryCallback.dart.fn.arg @ stack_zone_specification.dart:129 parent.runUnary.dart.fn.arg @ ng_zone.dart:190 async._rootRunUnary @ dart_sdk.js:29368 runUnary @ dart_sdk.js:28991 [_runUnary] @ ng_zone.dart:187 runUnary @ dart_sdk.js:29193 runUnaryGuarded @ dart_sdk.js:29114 dart.fn.arg @ dart_sdk.js:29146 load (async)
[_addEventListener] @ dart_sdk.js:57186 [dartx.addEventListener] @ dart_sdk.js:57176 [_tryResume] @ dart_sdk.js:99153 _EventStreamSubscription.new @ dart_sdk.js:99173 listen @ dart_sdk.js:98974 get first @ dart_sdk.js:10491 async.async.xhr.(anonymous function).first.then.dart.fn._ @ browser_client.dart:58 (anonymous function).dart.fn @ stack_zone_specification.dart:129 [_run] @ stack_zone_specification.dart:209 parent.registerUnaryCallback.dart.fn.arg @ stack_zone_specification.dart:129 parent.runUnary.dart.fn.arg @ ng_zone.dart:190 async._rootRunUnary @ dart_sdk.js:29365 runUnary @ dart_sdk.js:28991 [_runUnary] @ ng_zone.dart:187 runUnary @ dart_sdk.js:29193 handleValue @ dart_sdk.js:25288 handleValueCallback @ dart_sdk.js:25750 _propagateToListeners @ dart_sdk.js:25780 [_complete] @ dart_sdk.js:25634 async._cancelAndValue @ dart_sdk.js:27687 subscription.listen.dart.fn.value @ dart_sdk.js:10492 dart._checkAndCall @ dart_sdk.js:4656 dart.dcall @ dart_sdk.js:4661 (anonymous function).html$._wrapZone.dart.fn.e @ dart_sdk.js:99172 (anonymous function).dart.fn @ stack_zone_specification.dart:129 [_run] @ stack_zone_specification.dart:209 parent.registerUnaryCallback.dart.fn.arg @ stack_zone_specification.dart:129 parent.runUnary.dart.fn.arg @ ng_zone.dart:190 async._rootRunUnary @ dart_sdk.js:29368 runUnary @ dart_sdk.js:28991 [_runUnary] @ ng_zone.dart:187 runUnary @ dart_sdk.js:29193 runUnaryGuarded @ dart_sdk.js:29114 dart.fn.arg @ dart_sdk.js:29146 load (async)
[_addEventListener] @ dart_sdk.js:57186 [dartx.addEventListener] @ dart_sdk.js:57176 [_tryResume] @ dart_sdk.js:99153 _EventStreamSubscription.new @ dart_sdk.js:99173 listen @ dart_sdk.js:98974 get first @ dart_sdk.js:10491 send @ browser_client.dart:52 onValue @ dart_sdk.js:23385 (anonymous function).dart.fn @ stack_zone_specification.dart:129 [_run] @ stack_zone_specification.dart:209 parent.registerUnaryCallback.dart.fn.arg @ stack_zone_specification.dart:129 parent.runUnary.dart.fn.arg @ ng_zone.dart:190 async._rootRunUnary @ dart_sdk.js:29365 runUnary @ dart_sdk.js:28991 [_runUnary] @ ng_zone.dart:187 runUnary @ dart_sdk.js:29193 handleValue @ dart_sdk.js:25288 handleValueCallback @ dart_sdk.js:25750 _propagateToListeners @ dart_sdk.js:25780 [_completeWithValue] @ dart_sdk.js:25643 (anonymous function).scheduleMicrotask.dart.fn @ dart_sdk.js:25661 safeMicrotask @ ng_zone.dart:163 [_run] @ stack_zone_specification.dart:209 parent.registerCallback.dart.fn @ stack_zone_specification.dart:119 parent.run.dart.fn @ ng_zone.dart:178 async._rootRun @ dart_sdk.js:29359 run @ dart_sdk.js:28985 [_run] @ ng_zone.dart:175 run @ dart_sdk.js:29186 runGuarded @ dart_sdk.js:29106 dart.fn @ dart_sdk.js:29142 async._microtaskLoop @ dart_sdk.js:25990 async._startMicrotaskLoop @ dart_sdk.js:25996 internalCallback @ dart_sdk.js:26066 childList (async)
dart.fn.callback @ dart_sdk.js:26076 _scheduleImmediate @ dart_sdk.js:26052 async._scheduleAsyncCallback @ dart_sdk.js:26010 async._rootScheduleMicrotask @ dart_sdk.js:29404 scheduleMicrotask @ dart_sdk.js:29028 [_scheduleMicrotask] @ ng_zone.dart:171 scheduleMicrotask @ dart_sdk.js:29237 async.scheduleMicrotask @ dart_sdk.js:26048 schedule @ dart_sdk.js:26968 [_setPendingEvents] @ dart_sdk.js:23798 [_createSubscription] @ dart_sdk.js:26927 listen @ dart_sdk.js:23656 listen @ dart_sdk.js:26156 toBytes @ byte_stream.dart:24 send @ browser_client.dart:43 runBody @ dart_sdk.js:23404 async.async @ dart_sdk.js:23431 send @ browser_client.dart:42 _sendUnstreamed @ base_client.dart:171 runBody @ dart_sdk.js:23404 async.async @ dart_sdk.js:23431 [_sendUnstreamed] @ base_client.dart:152 get @ base_client.dart:34 search @ place_search_service.dart:16 runBody @ dart_sdk.js:23404 async.async @ dart_sdk.js:23431 search @ place_search_service.dart:14 search @ place_list_component.dart:54 runBody @ dart_sdk.js:23404 async.async @ dart_sdk.js:23431 search @ place_list_component.dart:50 [_handle_click_15_0] @ place_list_component.template.dart:160 src__core__linker__app_view_utils.appViewUtils.eventManager.getZone.runGuarded.dart.fn @ app_view.dart:619 parent.run.dart.fn @ ng_zone.dart:178 async._rootRun @ dart_sdk.js:29359 run @ dart_sdk.js:28985 [_run] @ ng_zone.dart:175 run @ dart_sdk.js:29186 runGuarded @ dart_sdk.js:29106 runGuarded @ ng_zone.dart:333 dart.fn.event`

1
Temporarily out throw _handleError(e); so that we can see the actual source of the exception. Then relaunch. What is the new stack trace?Patrice Chalin
* Temporarily comment out ...Patrice Chalin
I get following error: EXCEPTION: TypeError: Cannot read property 'Symbol(dartx.length)' of undefined. Strange, because I should receive 2 results. Added the Stacktrace above.Christopher Armstrong
Found the error. Actually in the Mock interface, it was dynamic _extractData(Response resp) => json.decode(resp.body)[data];, but in the Aqueduct interface the response is not enclosed in a JSON "data" tag. So changing it to dynamic _extractData(Response resp) => json.decode(resp.body); solved my problem. Apologies, but I still have my difficulties with debugging.Christopher Armstrong
I'm glad that you found the error.Patrice Chalin

1 Answers

3
votes

Found the error. Actually in the Mock interface, it was:

dynamic _extractData(Response resp) => json.decode(resp.body)[data];

But in the Aqueduct interface the response is not enclosed in a JSON "data" tag. So changing it to

dynamic _extractData(Response resp) => json.decode(resp.body); 

solved my problem.

So when getting an error such as:

TypeError: Cannot read property 'Symbol(dartx.length)' of undefined

it most likely means, that the response might not contain the correct json.