chromix-too icon indicating copy to clipboard operation
chromix-too copied to clipboard

SyntaxError: Unexpected end of JSON input

Open eyalev opened this issue 8 years ago • 7 comments

I installed chromix-too and everything worked for about an hour but now when I run something, e.g:

$ chromix-too focus gmail

I get the following error:


undefined:1
{"path":"chrome.tabs.query","args":[{}],"clientId":"1208377027-2","response":[[{"active":false,"audible":false,"autoDiscardable":true,"discarded":false,"favIconUrl":"https://www.google.co.il/images/branding/product/ico/googleg_lodp.ico","height":990,"highlighted":false,"id":209,"incognito":false,"index":0,"mutedInfo":{"muted":false},"pinned":false,"selected":false,"status":"complete","title":"python click alias - Google Search","url":"https://www.google.co.il/search?espv=2&q=python+click+alias&oq=python+click+alias&gs_l=serp.3..0.7093056.7094207.0.7094648.6.5.0.1.1.0.402.552.0j1j4-1.2.0....0...1c.1.64.serp..3.3.553...0i67k1.fXeBCtS1RDA","width":1855,"windowId":206},{"active":false,"audible":false,"autoDiscardable":true,"discarded":false,"height":990,"highlighted":false,"id":214,"incognito":false,"index":1,"mutedInfo":{"muted":false},"openerTabId":209,"pinned":false,"selected":false,"status":"complete","title":"Utilities — Click Documentation (5.0)","url":"http://click.pocoo.org/5/utils/","widt

SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at Socket.<anonymous> (/usr/lib/node_modules/chromix-too/chromix-too.js:32:25)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:189:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at Socket.Readable.push (_stream_readable.js:134:10)
    at Pipe.onread (net.js:551:20)

The server give the following output:

$ chromix-too-server
listening on: /home/eyalev/.chromix-too.sock
Mon Feb 27 2017 14:54:41 GMT+0200 (IST): websocket client connected


events.js:161
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at exports._errnoException (util.js:1023:11)
    at Pipe.onread (net.js:572:26)

Is there a way to fix this?

I'm running on Ubuntu 14.04.

(And thanks for the awesome project!)

eyalev avatar Feb 27 '17 13:02 eyalev

Ok, so chromix is now working again, I don't really know what happened. Closing for now. Thanks.

eyalev avatar Feb 27 '17 13:02 eyalev

Hmm.

I've no idea what was going on either. Glad it fixed itself!

smblott-github avatar Feb 27 '17 17:02 smblott-github

Happened again right now Seems to be related to the number of tabs open. When I have more than 122 tabs (123 and above) I get this error. When I close tabs to get to 122 or below - chromix works great. Is there a way to fix this?

eyalev avatar Feb 28 '17 12:02 eyalev

A couple of things...

  1. I can't reproduce this. I created 150 tabs and - while it was a bit slow - nothing failed.
  2. If it's triggered by more than exactly 122 tabs (or any number), then It seems really quite unlikely, on the face of it, that this is a chromix-too issue. There really are no numbers build into chromix-too.

If you're able to reproduce this reliably then it would be helpful to hear what if anything is appearing on the dev console in Chrome:

  • go here: chrome://extensions/
  • enable developer mode
  • open the background page for chromix-too
  • is there anything interesting appearing on the console?

smblott-github avatar Feb 28 '17 13:02 smblott-github

Followed the steps.

WebSocket connection to 'ws://localhost:7442/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
tryConnect @ background.js:68
background.js:59 disconnected, retry connection in 5000ms...
background.js:74 connected: ws://localhost:7442/
# All works fine with less tabs
# Time goes by..
# Here I opened more tabs and executed `chromix-too ls`
background.js:59 disconnected, retry connection in 5000ms...
background.js:74 connected: ws://localhost:7442/
WebSocket connection to 'ws://localhost:7442/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
tryConnect @ background.js:68
background.js:59 disconnected, retry connection in 5000ms...
background.js:74 connected: ws://localhost:7442/
background.js:68 WebSocket connection to 'ws://localhost:7442/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

Don't see something interesting..

eyalev avatar Feb 28 '17 13:02 eyalev

I'm running into the same problem, when fetching many cookies from Chrome:

SyntaxError: Unexpected token d in JSON at position 65532
    at JSON.parse (<anonymous>)
    at Socket.<anonymous> (/usr/lib/node_modules/chromix-too/chromix-too.js:32:25)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:178:18)
    at Socket.Readable.push (_stream_readable.js:136:10)
    at Pipe.onread (net.js:560:20)

Only happens when there are 100+ cookies.

It seems there is a limit of 65536 characters somewhere. Where would this limitation most likely be? In the JSON serializer, websocket or Chrome itself?

http://stackoverflow.com/questions/22034824/websocket-not-able-to-send-receive-string-longer-than-65536-characters

alxppp avatar Apr 26 '17 09:04 alxppp

ping @smblott-github this issue is a blocker for using it, almost all commands hit that bug

Note I have "large urls" caused by the awesome extension "the great suspender" which transforms stale tabs into png's, see https://chrome.google.com/webstore/detail/the-great-suspender/klbibkeccnjlkjkiokjodocebajanakg?hl=en

timotheecour avatar Apr 09 '20 04:04 timotheecour