Closed elliette closed 2 years ago
Getting a JS type error (TypeError: a.gdt is not a function) after compiling the Dart Debug Extension with dart2js, but not when compiling it with DDC.
TypeError: a.gdt is not a function
The changes that triggered this are here: https://github.com/dart-lang/webdev/pull/1729
Got help offline from @srujzs, dart2js compilation works as expected if evalResponse is given a JS-interop type (change), therefore closing.
evalResponse
Getting a JS type error (
TypeError: a.gdt is not a function
) after compiling the Dart Debug Extension with dart2js, but not when compiling it with DDC.The changes that triggered this are here: https://github.com/dart-lang/webdev/pull/1729
Details:
Original Dart:
``` FutureDart2JS (fails):
**Error is `TypeError: a.gdt is not a function` (8th line from bottom)** ``` A.hr.prototype={ $1(a){var s,r=this.a if(a==null){s=A.i9(null) s.error=J.i6(self.JSON,J.cx(J.ay(self.chrome))) r.$1(s)}else r.$1(a)}, $0(){return this.$1(null)}, $C:"$1", $R:0, $D(){return[null]}, $S:45} A.i0.prototype={ $1(a){if(a==null)J.cx(J.ay(self.chrome))}, $0(){return this.$1(null)}, $C:"$1", $R:0, $D(){return[null]}, $S:46} A.hE.prototype={ $1(a){var s if(a!=null){s=a.gdt() if(s!=null)s.gdG()}window.toString s=typeof console!="undefined" s.toString if(s)window.console.warn("Unable to debug app. Missing Dart debugging global variables") this.a.aW(!1) return}, $S:2} ```DDC (succeeds):
``` background._tryAttach = function _tryAttach(contextId, tab, launchInChromeDevTools) { return async.async(core.bool, function* _tryAttach() { let successCompleter = T.CompleterOfbool().new(); dart.global.chrome.debugger.sendCommand({tabId: tab.id}, "Runtime.evaluate", {expression: "[window.$dartExtensionUri, window.$dartAppId, window.$dartAppInstanceId, window.$dwdsVersion]", returnByValue: true, contextId: contextId}, js.allowInterop(core.Function, dart.fn(evalResponse => { let t3, t2, t2$, t2$0, t2$1, t2$2, t2$3; let value = (t2 = evalResponse, t2 == null ? null : (t3 = dart.dload(t2, 'result'), t3 == null ? null : dart.dload(t3, 'value'))); let extensionUri = T.StringN().as((t2$ = value, t2$ == null ? null : dart.dsend(t2$, '_get', [0]))); let appId = T.StringN().as((t2$0 = value, t2$0 == null ? null : dart.dsend(t2$0, '_get', [1]))); let instanceId = T.StringN().as((t2$1 = value, t2$1 == null ? null : dart.dsend(t2$1, '_get', [2]))); let dwdsVersion = T.StringN().as((t2$2 = value, t2$2 == null ? null : dart.dsend(t2$2, '_get', [3]))); if (extensionUri == null || appId == null || instanceId == null) { html.window[$console].warn("Unable to debug app. Missing Dart debugging global variables"); successCompleter.complete(false); return; } background._startSseClient(core.Uri.parse(extensionUri), appId, instanceId, contextId, tab, (t2$3 = dwdsVersion, t2$3 == null ? "0.0.0" : t2$3), launchInChromeDevTools); successCompleter.complete(true); }, T.dynamicToNull()))); return successCompleter.future; }); }; ```