Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug console error Unimplemented console API: undefined #201

Closed
erenozmeral opened this issue Oct 28, 2016 · 19 comments · Fixed by #227
Closed

Debug console error Unimplemented console API: undefined #201

erenozmeral opened this issue Oct 28, 2016 · 19 comments · Fixed by #227

Comments

@erenozmeral
Copy link

Unimplemented console API: undefined

hello,

I am getting this error message instead of any exception messages or console.log messages when i try to debug ionic cordova project on an android device. App is working fine on device.

do you have any ideas how to solve it?

thank you.

@MSLaguana
Copy link
Member

When do you get that message? Is VSCode still in debug mode, with the arrow and the pause symbol etc? Is that message printed to the debug console, and is it the only thing there?

If you try debugging the Simulate target, does that have the same error?

@erenozmeral
Copy link
Author

erenozmeral commented Oct 28, 2016

error message is printing to the debug console instead of console.log messages and error codes. yes VSCode is still in debug mode and the app works fine. i am having the same result with "Simulate Android in browser" option. on android emulator everything works fine.

i tried to reinstall the extension but it doesn't work.

Launching for android (This may take a while)...
App successfully launched
Attaching to android
Forwarding debug port
Attaching to app.
Unimplemented console API: undefined
Unimplemented console API: undefined
Unimplemented console API: undefined
Unimplemented console API: undefined
Unimplemented console API: undefined

this is my launch.json file:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Run Android on device",
            "type": "cordova",
            "request": "launch",
            "platform": "android",
            "target": "device",
            "port": 9222,
            "sourceMaps": true,
            "cwd": "${workspaceRoot}",
            "ionicLiveReload": false
        },
        {
            "name": "Run iOS on device",
            "type": "cordova",
            "request": "launch",
            "platform": "ios",
            "target": "device",
            "port": 9220,
            "sourceMaps": true,
            "cwd": "${workspaceRoot}",
            "ionicLiveReload": false
        },
        {
            "name": "Attach to running android on device",
            "type": "cordova",
            "request": "attach",
            "platform": "android",
            "target": "device",
            "port": 9222,
            "sourceMaps": true,
            "cwd": "${workspaceRoot}"
        },
        {
            "name": "Attach to running iOS on device",
            "type": "cordova",
            "request": "attach",
            "platform": "ios",
            "target": "device",
            "port": 9220,
            "sourceMaps": true,
            "cwd": "${workspaceRoot}"
        },
        {
            "name": "Run Android on emulator",
            "type": "cordova",
            "request": "launch",
            "platform": "android",
            "target": "emulator",
            "port": 9222,
            "sourceMaps": true,
            "cwd": "${workspaceRoot}",
            "ionicLiveReload": false
        },
        {
            "name": "Run iOS on simulator",
            "type": "cordova",
            "request": "launch",
            "platform": "ios",
            "target": "emulator",
            "port": 9220,
            "sourceMaps": true,
            "cwd": "${workspaceRoot}",
            "ionicLiveReload": false
        },
        {
            "name": "Attach to running android on emulator",
            "type": "cordova",
            "request": "attach",
            "platform": "android",
            "target": "emulator",
            "port": 9222,
            "sourceMaps": true,
            "cwd": "${workspaceRoot}"
        },
        {
            "name": "Attach to running iOS on simulator",
            "type": "cordova",
            "request": "attach",
            "platform": "ios",
            "target": "emulator",
            "port": 9220,
            "sourceMaps": true,
            "cwd": "${workspaceRoot}"
        },
        {
            "name": "Serve to the browser (ionic serve)",
            "type": "cordova",
            "request": "launch",
            "platform": "serve",
            "cwd": "${workspaceRoot}",
            "devServerAddress": "localhost",
            "sourceMaps": true,
            "ionicLiveReload": true
        },
        {
            "name": "Simulate Android in browser",
            "type": "cordova",
            "request": "launch",
            "platform": "android",
            "target": "chrome",
            "simulatePort": 8000,
            "livereload": true,
            "sourceMaps": true,
            "cwd": "${workspaceRoot}"
        },
        {
            "name": "Simulate iOS in browser",
            "type": "cordova",
            "request": "launch",
            "platform": "ios",
            "target": "chrome",
            "simulatePort": 8000,
            "livereload": true,
            "sourceMaps": true,
            "cwd": "${workspaceRoot}"
        }
    ]
}

thank you

@MSLaguana
Copy link
Member

Ah, it looks like you've hit a bug in vscode-chrome-debug, the underlying library which we use to debug the webviews: https://github.com/Microsoft/vscode-chrome-debug-core/blob/master/src/chrome/consoleHelper.ts#L46

It would be helpful if you could make a tweak to the extension so we can try to find out the cause:

  • Go to your vscode extension directory, either C:\Users\<user>\.vscode\extensions\ or ~/.vscode/extensions, then go to vsmobile.cordova-tools-1.2.3/node_modules/vscode-chrome-debug-core/out/src/chrome/ and open up consoleHelper.js.
  • Look around line 37 for outputText = 'Unimplemented console API: ' + m.type;
  • change that to outputText = 'Unimplemented console API: ' + JSON.stringify(m);

Once you've done that, please let us know what errors you get now. There may be some change or edge-case in the debugging protocol that we weren't aware of.

@erenozmeral
Copy link
Author

thank you for your quick response MSLaguana.

here are the messages.

Unimplemented console API: {"source":"console-api","level":"log","text":"LANGUAGE SUCCESS -> en","url":"file:///android_asset/www/js/app.js","line":119,"column":21}
Unimplemented console API: {"source":"console-api","level":"log","text":"No Problem in db!","url":"file:///android_asset/www/js/app.js","line":105,"column":27}
Unimplemented console API: {"source":"console-api","level":"log","text":"OPEN database: db.db","url":"file:///android_asset/www/plugins/cordova-sqlite-storage/www/SQLitePlugin.js","line":175,"column":15}
Unimplemented console API: {"source":"console-api","level":"log","text":"OPEN database: db.db - OK","url":"file:///android_asset/www/plugins/cordova-sqlite-storage/www/SQLitePlugin.js","line":179,"column":19}
Unimplemented console API: {"source":"console-api","level":"log","text":"DB opened: db.db","url":"file:///android_asset/www/plugins/cordova-sqlite-storage/www/SQLitePlugin.js","line":80,"column":15}

outputText = m.text;
this is enough for me for now :)

@verylongword
Copy link

I also encounter this problem
IN Visual Studio Code debug console:

App successfully launched
Attaching to android
Forwarding debug port
Attaching to app.
Unimplemented console API: undefined
Unimplemented console API: undefined
Unimplemented console API: undefined
Unimplemented console API: undefined
Unimplemented console API: undefined
Unimplemented console API: undefined
Unimplemented console API: undefined

Unimplemented console API: undefined

Unfortunately for me I have real bug(s) in my code so this attempt at debugging on my phone gives me a blank screen.
Any suggestions for a workaround would be much appreciated

@MSLaguana
Copy link
Member

For a temporary workaround, you can follow the steps in #201 (comment) and then set something like outputText = m.text

@myth815
Copy link

myth815 commented Nov 14, 2016

image

@julientype
Copy link

julientype commented Nov 24, 2016

AHHHH that worked..... MSLaguana
now it even works when i device load for cordova..... but no brake points in it....
fix your code microsoft

works in chrome now.....

tk julien
http://3taccount.com

@zompad
Copy link

zompad commented Nov 30, 2016

Yes I have encountered the same as issue and have done the @MSLanguana workaround which I think is very "dirty".

Like @julientype I cannot do break points, I get a grey "breakpoint unverified" in the left gutter.

Please can someone in Microsoft help/fix ... please.

@KinsonDigital
Copy link

Is this a fix that is going to be released anytime soon?

@MSLaguana
Copy link
Member

It's something that we're looking into, but it isn't as simple as you might hope. The correct fix for this is to update a dependency we have to a newer version (vscode-chrome-debug-core specifically) but between the version we use and the latest version there were some breaking changes, so we need to resolve those before we can fix the problem properly.

@KinsonDigital
Copy link

Absolutely understandable. Thank you so much @MSLaguana.

@jmesa-sistel
Copy link

Any news?

@MSLaguana
Copy link
Member

I have a potential fix in #227 but I was intending to test it out a bit more before publishing. If you would like to check out the repo and see if it fixes things for you without introducing other issues, that'd be helpful and give me more confidence in putting out an update with the fix.

@jmesa-sistel
Copy link

@MSLaguana
Ok, I'll do it, but I have to do it tomorrow, thanks for your fast response.

@jmesa-sistel
Copy link

jmesa-sistel commented Jan 13, 2017

I have installed the last code in my Windows10 and the problem persists.
Unimplemented console API: {"source":"console-api","level":"log","text":"Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.","url":"http://192.168.114.208:8100/build/main.js","line":1845,"column":13}

PS
Sorry I tested master instead updateChromeDebugger

but now I cannot attach to the device:

Attaching to android
Forwarding debug port
Attaching to app.
Cannot read property 'toLowerCase' of undefined
Error processing "attach": TypeError: Cannot read property 'toLowerCase' of undefined
    at CordovaPathTransformer.attach (C:\Users\jmesa.SISTEL\.vscode\extensions\vscode-cordova\out\src\debugger\cordovaPathTransformer.js:26:39)
    at CordovaDebugAdapter.attach (C:\Users\jmesa.SISTEL\.vscode\extensions\vscode-cordova\node_modules\vscode-chrome-debug-core\out\src\chrome\chromeDebugAdapter.js:99:31)
    at telemetryHelper_1.TelemetryHelper.determineProjectTypes.then.then.then (C:\Users\jmesa.SISTEL\.vscode\extensions\vscode-cordova\out\src\debugger\cordovaDebugAdapter.js:131:30)
    at _fulfilled (C:\Users\jmesa.SISTEL\.vscode\extensions\vscode-cordova\node_modules\q\q.js:834:54)
    at self.promiseDispatch.done (C:\Users\jmesa.SISTEL\.vscode\extensions\vscode-cordova\node_modules\q\q.js:863:30)
    at Promise.promise.promiseDispatch (C:\Users\jmesa.SISTEL\.vscode\extensions\vscode-cordova\node_modules\q\q.js:796:13)
    at C:\Users\jmesa.SISTEL\.vscode\extensions\vscode-cordova\node_modules\q\q.js:604:44
    at runSingle (C:\Users\jmesa.SISTEL\.vscode\extensions\vscode-cordova\node_modules\q\q.js:137:13)
    at flush (C:\Users\jmesa.SISTEL\.vscode\extensions\vscode-cordova\node_modules\q\q.js:125:13)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
error: listener 'tcp:9222' not found

PS2
More info:
JSON.stringify(args) from CordovaPathTransformer.attach function'
{"port":9222,"webRoot":"d:\\web\\tests\\cutePuppyPics","skipFileRegExps":["^chrome-extension:.*"]}

@jmesa-sistel
Copy link

jmesa-sistel commented Jan 13, 2017

@MSLaguana
If I change in cordovaDebugAdapter.ts in public attach(attachArgs: ICordovaAttachRequestArgs): Promise<void> function (about line 202)
return super.attach(processedAttachArgs);
by
return super.attach(attachArgs);
Now everything works, but I guess you want to merge processedAttachArgs & attachArgs but I am not sure.

PS:
After reading the code again maybe you want to return attachArgs in attachAndroid function, I do not understand why you return port & webRoot only (line 362)

@MSLaguana
Copy link
Member

Ah thanks for testing that out. I had been testing with the simulate target, but I had forgotten we had special cases for android and iOS targets. I'll investigate that further and get a fix in.

@MSLaguana
Copy link
Member

I've published a new build which should have these fixes.

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

Successfully merging a pull request may close this issue.

8 participants