gwomacks/php-debug

0.3.4 SyntaxError Unexpected token U in JSON at position 45 at JSON.parse

msitarzewski opened this issue · 8 comments

Version 0.3.4 - I can't get a debugging session to work. I have ports forwarded from my debug server (port 9001) at Digital Ocean to local port 9002. This has worked flawlessly in the past, but after upgrading to 0.3.x it hasn't. Attached is a screenshot of the console when a debugging session is requested. All software versions are the latest: PHP 7.2.5, xdebug 2.6.0

The session seems to connect, but hangs, seemingly because of this error.

screenshot 44

For what it's worth, this appears to be a Windows issue. The same setup works on macOS High Sierra.

Can you clear your php-debug config from config.cson and try again?

Indeed, happy to. Tried again, and the position changed to 42 from 45. That doesn't appear to be helpful. I've updated the screenshot for you.
screenshot 47

The error you're receiving is because the package is failing to parse your pathmaps. Can you provide your config here?

"php-debug":
showWelcome: false
xdebug:
pathMaps: "[{"remotePath":"/var/www","localPath":"C:\Users\msita\OneDrive\GitHub"}]"
welcome:
showOnStartup: false

Hmm, I'm not sure how it would have been saved like that but it should look like

"[{\"remotePath\":\"/var/www\",\"localPath\":\"C:\\Users\\msita\\OneDrive\\GitHub\"}]"

or

"[{\"remotePath\":\"/var/www\",\"localPath\":\"C:/Users/msita/OneDrive/GitHub\"}]"

I noticed after you posted that the escaped back slashes were indeed escaped (they were there in the config file). When I pasted in the first option of yours, nothing changed (they were escaped). The second option didn't work, but I was prompted for a path setup for a file that runs in the apache config:

php_value auto_prepend_file "/var/www/bootstrap.php"

I told php_debug not to use that file/path, and it was added to the path config as expected:

"[{"remotePath":"/var/www/ig","localPath":"C:/Users/msita/OneDrive/GitHub/ig"},{"remotePath":"/var/www/bootstrap.php","localPath":"!"}]"

Now the sessions are being rejected all together. Can I just ignore it, not reject it?

screenshot 50

Curious that this same config works on macOS.

Solved. The issue was that I was only using single backslashes in the php_debug settings interface (resulting in double backslashes in the config.cson file). Once I added the second backslash in the interface (resulting in \\\\ in the config.cson) it worked!