ReferenceError: DartObject is not defined
Asked Answered
C

1

6

My dart2js compiled Chrome Packaged App crashes with Uncaught Error: Instance of 'UnknownJavaScriptObject' and ReferenceError: DartObject is not defined.

The full stack trace follows

Uncaught Error: Instance of 'UnknownJavaScriptObject' echo_mco.dart.js:7913
Stack Trace: 
ReferenceError: DartObject is not defined
    at dart._convertToDart (chrome-extension://paadaccdfibbhkkhjaolagidoopakdik/echo_mco.dart.js:7422:34)
    at JsObject.$index (chrome-extension://paadaccdfibbhkkhjaolagidoopakdik/echo_mco.dart.js:7449:16)
    at dart.J.$index$asx (chrome-extension://paadaccdfibbhkkhjaolagidoopakdik/echo_mco.dart.js:8496:41)
    at chrome-extension://paadaccdfibbhkkhjaolagidoopakdik/echo_mco.dart.js:8874:12
    at Isolate.prototype.(anonymous function) (chrome-extension://paadaccdfibbhkkhjaolagidoopakdik/echo_mco.dart.js:9412:37)
    at chrome-extension://paadaccdfibbhkkhjaolagidoopakdik/echo_mco.dart.js:8871:25
    at Isolate.prototype.(anonymous function) (chrome-extension://paadaccdfibbhkkhjaolagidoopakdik/echo_mco.dart.js:9412:37)
    at RawDatagramSocket_bind_closure.call$0 (chrome-extension://paadaccdfibbhkkhjaolagidoopakdik/echo_mco.dart.js:3079:14)
    at dart.Future_Future$sync (chrome-extension://paadaccdfibbhkkhjaolagidoopakdik/echo_mco.dart.js:3381:28)
    at dart.RawDatagramSocket.static.RawDatagramSocket_bind (chrome-extension://paadaccdfibbhkkhjaolagidoopakdik/echo_mco.dart.js:3070:18)
Celanese answered 1/2, 2014 at 0:6 Comment(0)
C
6

This is caused by the interop.js script not being included properly. It must be included as

<script src="packages/browser/interop.js"></script>

and it must precede all other Dart related JavaScript includes. So the includes may for example look like this

<script src="packages/browser/interop.js"></script>
<script type="application/dart">export 'package:polymer/init.dart';</script>
<script src="packages/browser/dart.js"></script>

In a Chrome Packaged App that uses the chrome package the includes may look like this

<script src="packages/browser/interop.js"></script>
<script src="packages/chrome/bootstrap.js" defer></script>
<script src="echo_mco.dart" type="application/dart"></script> 

The problem was being discussed and solved at https://code.google.com/p/dart/issues/detail?id=15065

Celanese answered 1/2, 2014 at 0:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.