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.

ElmLS randomly crashes with Unexpected JSON error

See original GitHub issue

ElmLS runs just fine for a while, but after a couple minutes, something that I do will crash it with the following error:

SyntaxError: Unexpected number in JSON at position 1
    at JSON.parse (<anonymous>)
    at execaError.stderr.split.forEach (/usr/local/lib/node_modules/@elm-tooling/elm-language-server/out/providers/diagnostics/elmMakeDiagnostics.js:146:54)
    at Array.forEach (<anonymous>)
    at ElmMakeDiagnostics.<anonymous> (/usr/local/lib/node_modules/@elm-tooling/elm-language-server/out/providers/diagnostics/elmMakeDiagnostics.js:145:55)
    at Generator.throw (<anonymous>)
    at rejected (/usr/local/lib/node_modules/@elm-tooling/elm-language-server/out/providers/diagnostics/elmMakeDiagnostics.js:6:65)
    at process._tickCallback (internal/process/next_tick.js:68:7)

/usr/local/lib/node_modules/@elm-tooling/elm-language-server/node_modules/web-tree-sitter/tree-sitter.js:1
(function (exports, require, module, __filename, __dirname) { var Module=void 0!==Module?Module:{};!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():window.TreeSitter=t()}(0,function(){var e,t={};for(e in Module)Module.hasOwnProperty(e)&&(t[e]=Module[e]);Module.arguments=[],Module.thisProgram="./this.program",Module.quit=function(e,t){throw t},Module.preRun=[],Module.postRun=[];var n,r=!1,a=!1,i=!1;r="object"==typeof window,a="function"==typeof importScripts,i="object"==typeof process&&"function"==typeof require&&!r&&!a,n=!r&&!i&&!a;var o,l,u="";i?(u=__dirname+"/",Module.read=function shell_read(e,t){var n;return o||(o=require("fs")),l||(l=require("path")),e=l.normalize(e),n=o.readFileSync(e),t?n:n.toString()},Module.readBinary=function readBinary(e){var t=Module.read(e,!0);return t.buffer||(t=new Uint8Array(t)),assert(t.buffer),t},process.arg
abort({}). Build with -s ASSERTIONS=1 for more info.
[Error  - 4:03:26 PM] Connection to server got closed. Server will not be restarted.
[Error  - 4:03:26 PM] elm-language-server exited with code: 7

I’m not certain what is triggering this, but it might be the diagnostics.

Expected Behavior

Not to crash, or to restart if it crashes maybe?

Current Behavior

Crashes and I have to do a :CocRestart to fire it up again every couple minutes.

Possible Solution

Figure out what JSON is being returned, though I’m not sure how to do this.

Steps to Reproduce (for bugs)

  1. Open a src/test file in https://github.com/jschomay/subway-game/tree/rules-parser in vim using coc (other files may work too)
  2. Notice the ElmLS works for a while
  3. Make some changes, or maybe just wait for a while or view a diagnostic
  4. Notice ElmLS has crashed and :CocInfo shows the error above.

Context

I just want to use ElmLS with coc.

Your Environment

  • Version used: ElmLS 1.4.1, Elm elm@0.19.0-no-deps
  • Editor used: vim 8.1
  • Environment name and version (e.g. node.js 5.4): node v10.10.0
  • Operating System and version: OSX 10.11.6

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jschomaycommented, Sep 26, 2019

I tested it out and I think you’ve solved the problem (I am still getting the invalid JSON errors, but elmLS isn’t crashing).

[Info  - 8:02:36 PM] Diagnostics were requested due to a file open or save
[Warn  - 8:02:37 PM] Received an invalid json, skipping error.
[Warn  - 8:02:37 PM] Received an invalid json, skipping error.
[Warn  - 8:02:37 PM] Received an invalid json, skipping error.
... lots of these messages, then more normal logs
[Info  - 8:02:38 PM] Received new elm-analyse report with 24 messages
etc...

Thank you for fixing that. Hopefully the invalid JSON issue gets fixed eventually.

0reactions
andys8commented, Sep 25, 2019

@jschomay I think it’s not possible to install via npm (only). The repository has to be cloned, built and linked. There is a description how to to that here: https://github.com/elm-tooling/elm-language-server/blob/master/README.md#alternative-compile-and-install-from-source

Let me know if it works for you and feel free to ask for help if not.

Read more comments on GitHub >

github_iconTop Results From Across the Web

server crashes giving unexpected token in json error · Issue #120 ...
Expected Behavior. it should just work. Current Behavior. server crashes. Possible Solution. Tried both in linux and mac and also tried installing through ......
Read more >
Client crash calling Parse() method on invalid Json
Question/Problem Description. Client crashes when calling Parse() method on an invalid Json string. Client terminates calling Progress.Json.
Read more >
JSON Parse error when reading json object from file
Observing random crash when reading JSON file data to a JSON object. Here is the summary of the crash. The crash point is...
Read more >
How to avoid building apps that crash by parsing JSON the ...
First of all, if the response is a JSON array instead of a dictionary, your app will crash at runtime.
Read more >
Parsing JSON is a Minefield - Hacker News
So now I have fixed it to parse iteratively. It still crashes. Big surprise. Turns out the array destructor is also recursive, because...
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