question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Large websocket responses get truncated and cannot be parsed

See original GitHub issue

Description

Sometimes a very long response from the language server gets truncated and the relevant action is not performed. This appears to be somewhat random, because subsequent attempts can sometimes succeed.

Uncaught SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at i.readMessage (index.js:formatted:1)
    at index.js:formatted:1
    at WebSocket.e.onmessage (index.js:formatted:1)
readMessage @ index.js:formatted:1
(anonymous) @ index.js:formatted:1
e.onmessage @ index.js:formatted:1

The message truncates at less than 7k characters

Similar issue was reported in a different project using PHP backend here: https://github.com/beyondcode/dusk-dashboard/issues/20.

Reproduce

  1. Open an R notebook
  2. Type base:: (potentially press <kbd>Tab</kbd>, but should auto-invoke)
  3. See lack of completion suggestions and error in console

Expected behavior

  1. We may want to try to recover truncated JSON messages by parsing the viable portion (e.g. for completion it would make sense to show something rather than nothing, especially for extra long namespaces such as base in R)
  2. The error should not happen in the first place

Context

  • Operating System and version: Ubuntu 20.10
  • Browser and version: Chrome
  • JupyterLab version: 2.2.x

master on 2.1.2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
dpriedelcommented, Jan 24, 2021

I’ll try using my hack for a day or so and if I don’t run into any problems, I’ll create a PR

1reaction
dpriedelcommented, Jan 24, 2021

I believe I’m using the fixed code from above. I have jupyter-lsp 1.1.1 and jupyterlab-lsp 3.2.0

I’m seeing this truncated output with the Jedi language server, pretty much all the time.

By way of an experiment, I changed line 122 in the _read_content method of the stdio.py from ‘break’ to ‘continue’.

The problem went away.

I wonder if the problem is that this async consumer routine is reading output from an async producer routine which just is not ready with its next chunk of data – jedi language server not being the fastest tool in the shed.

So, maybe changing the ‘break’ to ‘continue’ and max_parts to some smaller number is a better way to go ??

I’m going to keep this change for a while and see how it goes.

Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Message sent truncated to the size of data received
So... After much debugging, I'm still stuck. I have figured out that the encrypted message is the entire string. However, what is sent...
Read more >
Request truncates large response body · Issue #1418 - GitHub
One thing I noticed is that JSON.parse fails silently, so in the case of an issue like this, we expect a JSON object,...
Read more >
WebSocket Client - Portal - StreamSets Docs
You can use the WebSocket Client origin to read REST response JSON data generated by Data ... Larger messages cannot be processed or...
Read more >
RFC 6455: The WebSocket Protocol
The format and parsing of headers is as defined in [RFC2616]. Once the client and server have both sent their handshakes, and if...
Read more >
Serverless SQL pool self-help - Azure Synapse Analytics
String or binary data would be truncated​​ You can fix this error by increasing the length of the column type: If your string...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found