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

Rescript language server crashes #77

Closed
mbergal opened this issue Feb 4, 2021 · 9 comments
Closed

Rescript language server crashes #77

mbergal opened this issue Feb 4, 2021 · 9 comments

Comments

@mbergal
Copy link

mbergal commented Feb 4, 2021


    at parseFileAndRange (/home/misha/.vscode/extensions/chenglou92.rescript-vscode-1.0.5/server/out/utils.js:186:129)
    at /home/misha/.vscode/extensions/chenglou92.rescript-vscode-1.0.5/server/out/utils.js:287:31
    at Array.forEach (<anonymous>)
    at Object.exports.parseCompilerLogOutput (/home/misha/.vscode/extensions/chenglou92.rescript-vscode-1.0.5/server/out/utils.js:285:23)
    at /home/misha/.vscode/extensions/chenglou92.rescript-vscode-1.0.5/server/out/server.js:51:54
    at Map.forEach (<anonymous>)
    at sendUpdatedDiagnostics (/home/misha/.vscode/extensions/chenglou92.rescript-vscode-1.0.5/server/out/server.js:49:19)
    at FSWatcher.<anonymous> (/home/misha/.vscode/extensions/chenglou92.rescript-vscode-1.0.5/server/out/server.js:112:5)
    at FSWatcher.emit (events.js:315:20)
    at FSWatcher.emitWithAll (/home/misha/.vscode/extensions/chenglou92.rescript-vscode-1.0.5/node_modules/chokidar/index.js:535:32)
(node:2178238) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2178238) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
/home/misha/.vscode/extensions/chenglou92.rescript-vscode-1.0.5/server/out/utils.js:186
    let [_source, file, startLine, startChar, optionalEndGroup, endLineOrChar, _colonPlusEndCharOrNothing, endCharOrNothing,] = fileAndRange.trim().match(regex);
                                                                                                                                ^

TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))
    at parseFileAndRange (/home/misha/.vscode/extensions/chenglou92.rescript-vscode-1.0.5/server/out/utils.js:186:129)
    at /home/misha/.vscode/extensions/chenglou92.rescript-vscode-1.0.5/server/out/utils.js:287:31
    at Array.forEach (<anonymous>)
    at Object.exports.parseCompilerLogOutput (/home/misha/.vscode/extensions/chenglou92.rescript-vscode-1.0.5/server/out/utils.js:285:23)
    at /home/misha/.vscode/extensions/chenglou92.rescript-vscode-1.0.5/server/out/server.js:51:54
    at Map.forEach (<anonymous>)
    at sendUpdatedDiagnostics (/home/misha/.vscode/extensions/chenglou92.rescript-vscode-1.0.5/server/out/server.js:49:19)
    at FSWatcher.<anonymous> (/home/misha/.vscode/extensions/chenglou92.rescript-vscode-1.0.5/server/out/server.js:112:5)
    at FSWatcher.emit (events.js:315:20)
    at FSWatcher.emitWithAll (/home/misha/.vscode/extensions/chenglou92.rescript-vscode-1.0.5/node_modules/chokidar/index.js:535:32)
[Error - 5:20:56 PM] Connection to server got closed. Server will not be restarted.
@shrihari689
Copy link

shrihari689 commented Feb 5, 2021

Yeah! This happens for me too from last week.

@chenglou
Copy link
Member

chenglou commented Feb 5, 2021

Can you both show me what your lib/bs/.compiler.log looks like?

@shrihari689
Copy link

lib/bs/.compiler.log

#Start(589717958)
#Done(589717959)

Error Logs from Output Tab on VS Code.

undefined:1

SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at c:\Users\SHRI HARI\.vscode\extensions\chenglou92.rescript-vscode-1.0.5\server\out\RescriptEditorSupport.js:57:31
    at ChildProcess.exithandler (child_process.js:319:5)
    at ChildProcess.emit (events.js:315:20)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
[Error - 2:28:03 pm] Connection to server got closed. Server will not be restarted.
[Error - 2:28:03 pm] Request textDocument/hover failed.
Error: Connection got disposed.
    at Object.dispose (c:\Users\SHRI HARI\.vscode\extensions\chenglou92.rescript-vscode-1.0.5\client\node_modules\vscode-jsonrpc\lib\main.js:904:25)
    at Object.dispose (c:\Users\SHRI HARI\.vscode\extensions\chenglou92.rescript-vscode-1.0.5\client\node_modules\vscode-languageclient\lib\client.js:74:35)
    at LanguageClient.handleConnectionClosed (c:\Users\SHRI HARI\.vscode\extensions\chenglou92.rescript-vscode-1.0.5\client\node_modules\vscode-languageclient\lib\client.js:2309:42)
    at LanguageClient.handleConnectionClosed (c:\Users\SHRI HARI\.vscode\extensions\chenglou92.rescript-vscode-1.0.5\client\node_modules\vscode-languageclient\lib\main.js:155:15)
    at closeHandler (c:\Users\SHRI HARI\.vscode\extensions\chenglou92.rescript-vscode-1.0.5\client\node_modules\vscode-languageclient\lib\client.js:2296:18)
    at CallbackList.invoke (c:\Users\SHRI HARI\.vscode\extensions\chenglou92.rescript-vscode-1.0.5\client\node_modules\vscode-jsonrpc\lib\events.js:62:39)
    at Emitter.fire (c:\Users\SHRI HARI\.vscode\extensions\chenglou92.rescript-vscode-1.0.5\client\node_modules\vscode-jsonrpc\lib\events.js:121:36)
    at closeHandler (c:\Users\SHRI HARI\.vscode\extensions\chenglou92.rescript-vscode-1.0.5\client\node_modules\vscode-jsonrpc\lib\main.js:240:26)
    at CallbackList.invoke (c:\Users\SHRI HARI\.vscode\extensions\chenglou92.rescript-vscode-1.0.5\client\node_modules\vscode-jsonrpc\lib\events.js:62:39)
    at Emitter.fire (c:\Users\SHRI HARI\.vscode\extensions\chenglou92.rescript-vscode-1.0.5\client\node_modules\vscode-jsonrpc\lib\events.js:121:36)
    at IPCMessageReader.fireClose (c:\Users\SHRI HARI\.vscode\extensions\chenglou92.rescript-vscode-1.0.5\client\node_modules\vscode-jsonrpc\lib\messageReader.js:111:27)
    at ChildProcess.<anonymous> (c:\Users\SHRI HARI\.vscode\extensions\chenglou92.rescript-vscode-1.0.5\client\node_modules\vscode-jsonrpc\lib\messageReader.js:213:45)
    at ChildProcess.emit (events.js:327:22)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)

Error Image

image

@chenglou
Copy link
Member

chenglou commented Feb 5, 2021

@shrihari689 would you mind creating a new issue? And have a minimal repro including the project files or such. Your case is a bit harder to debug

@mbergal
Copy link
Author

mbergal commented Feb 5, 2021

#Start(1612551350063)

  Warning number 27
  /home/misha/projects/productionmasons/web/auth/src/config/Config.res:10:22-27
  
   8 │ external stringifyAnyWithSpace: ('a, @bs.as(json`null`) _, int) => str
       ing = "stringify"
   9 │ 
  10 │ let validateConfig = config => {
  11 │   let googleApplicationCredentialsPath =
  12 │     NodeJs.Process.env(NodeJs.Process.process)->Js.Dict.get("GOOGLE_AP
       PLICATION_CREDENTIALS")
  
  unused variable config.
  

  Warning number 34
  /home/misha/projects/productionmasons/web/auth/src/Db.res:118:3-23
  
  116 ┆ }
  117 ┆ @decco
  118 ┆ type users = array<t>
  119 ┆ 
  120 ┆ let findByUid = (t_db: t_db, ~logger, uid: string): AsyncResult.t<opt
        ion<t>, [> #Exn(exn)]> => {
  
  unused type users.
  

  Warning number 32
  /home/misha/projects/productionmasons/web/auth/src/Db.res
  
  unused value users_encode.
  

  Warning number 27
  /home/misha/projects/productionmasons/web/auth/src/Db.res:130:34-40
  
  128 ┆ }
  129 ┆ 
  130 ┆ let findByEmail = (t_db: t_db, ~logger, email: string) => {
  131 ┆   let query = `
  132 ┆   SELECT * FROM users 
  
  unused variable logger.
  

  Warning number 34
  /home/misha/projects/productionmasons/web/auth/src/Db.res:146:3-24
  
  144 ┆ 
  145 ┆ @decco
  146 ┆ type ins2 = array<ins>
  147 ┆ 
  148 ┆ let addFirebaseToUser = (t_db: t_db, ~logger: Logger.t, ~id: string, 
        firebaseId) => {
  
  unused type ins2.
  

  Warning number 32
  /home/misha/projects/productionmasons/web/auth/src/Db.res
  
  unused value ins2_encode.
  

  Warning number 27
  /home/misha/projects/productionmasons/web/auth/src/Db.res:160:25-30
  
  158 ┆   t_db
  159 ┆   ->Pg.queryArray(~query, ~values, ~decoder=ins2_decode, ())
  160 ┆   ->AsyncResult.mapOk(result => Ok("a"))
  161 ┆ }
  162 ┆ 
  
  unused variable result.
  

  Warning number 27
  /home/misha/projects/productionmasons/web/auth/src/Db.res:188:25-30
  
  186 │     t_db
  187 │     ->Pg.queryArray(~query, ~values, ~decoder=ins2_decode, ())
  188 │     ->AsyncResult.mapOk(result => Ok(""))
  189 │   }
  190 │ }
  
  unused variable result.
  
#Done(1612551350118)

@chenglou
Copy link
Member

chenglou commented Feb 6, 2021

@mbergal thanks; that Db.res with warning 32 doesn't produce a code preview. Can you show me what's on that ins2_encode line?

@mbergal
Copy link
Author

mbergal commented Feb 6, 2021

Here's the fragment

module User = {
  @decco
  type t = {
    id: string,
    firebase_uid: string,
    display_name: string,
    email: string,
    phone: string,
  }
  @decco
  type users = array<t>

  let findByUid = (t_db: t_db, ~logger, uid: string): AsyncResult.t<option<t>, [> #Exn(exn)]> => {
    logger->Logger.debug(~msg="findUserByUid", ())
    let query = "SELECT * FROM users WHERE firebase_uid = $1 LIMIT 1"
    let values = [uid]

    t_db
    ->Pg.queryArray(~query, ~values, ~decoder=users_decode, ())
    ->AsyncResult.mapOk(result => Ok(result->Array.get(0)))
  }

I think the warning is related to users_encode function generated by decco ppx.

@chenglou
Copy link
Member

chenglou commented Feb 6, 2021

Ok, so this is caused the ppx violating the assumption that we always display the location. I was a bit lenient in the error display in case there’s no location, but was stricter in the editor plugin's parsing of the display. Guess I’ll have to be lenient in the latter as well... in case there are other bad ppxes.

It sucks but we'll have to silence the errors by being lenient. If I have time, I can also check into decco to see where this comes from maybe...

@cristianoc
Copy link
Collaborator

It's also unclear that a warning should be given, unless you expect that both serializers and deserializers are always used.
Other ppx's explicitly disable the unused warning:
https://github.com/ocaml-ppx/ppx/blob/master/src/deriving.ml#L525

@sekunho sekunho mentioned this issue Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants