Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Missing hash key "<name_of_file>" #59

Closed
bew opened this issue Mar 10, 2018 · 3 comments · Fixed by #92
Closed

Missing hash key "<name_of_file>" #59

bew opened this issue Mar 10, 2018 · 3 comments · Fixed by #92

Comments

@bew
Copy link
Contributor

bew commented Mar 10, 2018

So I've got Scry working sometime in Neovim!!

Sometime I have a weird bug, where restarting the editor and scry doesn't resolve.
The log is: (I've just removed the huuuuge dependency graph line)

I, [2018-03-10 02:15:44 -08:00 #3622]  INFO -- : Scry is looking into your code...
D, [2018-03-10 02:15:44 -08:00 #3622] DEBUG -- : Content-Length: 413
D, [2018-03-10 02:15:44 -08:00 #3622] DEBUG -- : 
D, [2018-03-10 02:15:44 -08:00 #3622] DEBUG -- : {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"textDocument":{"completion":{"completionItem":{"commitCharactersSupport":null,"documentationFormat":null,"snippetSupport":false},"dynamicRegistration":null}}},"initializationOptions":null,"processId":3611,"rootPath":"/home/lesell_b/tests/crystal/dbus/pure_dbus","rootUri":"file:///home/lesell_b/tests/crystal/dbus/pure_dbus","trace":"off"},"id":8}
D, [2018-03-10 02:15:44 -08:00 #3622] DEBUG -- : initialize
D, [2018-03-10 02:15:44 -08:00 #3622] DEBUG -- : Starting to build dependancy graph for these paths: /home/lesell_b/tests/crystal/dbus/pure_dbus/lib
lib
/usr/lib/crystal
/home/lesell_b/tests/crystal/dbus/pure_dbus
D, [2018-03-10 02:15:44 -08:00 #3622] DEBUG -- : Content SEND: Content-Length: 244

{"jsonrpc":"2.0","id":8,"result":{"capabilities":{"textDocumentSync":1,"documentFormattingProvider":true,"definitionProvider":true,"documentSymbolProvider":true,"completionProvider":{"resolveProvider":true,"triggerCharacters":[".","\"","/"]}}}}
D, [2018-03-10 02:15:44 -08:00 #3622] DEBUG -- : Content-Length: 327
D, [2018-03-10 02:15:44 -08:00 #3622] DEBUG -- : 
D, [2018-03-10 02:15:44 -08:00 #3622] DEBUG -- : {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"crystal","text":"class Foo\n  def self.bar(io : IO)\n  end\nend\n\nclass Bar\n  def self.bla\n    3\n  end\n\n  def ljkh\n    2\n  end\nend\n\nBar.new.","uri":"file:///home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr","version":0}}}
D, [2018-03-10 02:15:44 -08:00 #3622] DEBUG -- : textDocument/didOpen
D, [2018-03-10 02:15:45 -08:00 #3622] DEBUG -- : Content SEND: Content-Length: 3013

{"jsonrpc":"2.0","error":{"code":-32001,"message":"expecting any of these tokens: IDENT, CONST, +, -, *, /, %, |, &, ^, **, <<, <, <=, ==, !=, =~, !~, >>, >, >=, <=>, ===, [], []=, []?, [ (not 'EOF')","data":["/usr/lib/crystal/compiler/crystal/syntax/lexer.cr:2751:9 in 'raise'","/usr/lib/crystal/compiler/crystal/syntax/lexer.cr:2750:5 in 'raise'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:183:11 in 'check'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:606:11 in 'parse_atomic_method_suffix'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:558:7 in 'parse_atomic_with_method'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:549:9 in 'parse_prefix'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:533:5 in 'parse_pow'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:532:5 in 'parse_mul_or_div'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:498:7 in 'parse_add_or_sub'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:493:5 in 'parse_shift'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:492:5 in 'parse_logical_and'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:491:5 in 'parse_logical_or'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:490:5 in 'parse_cmp'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:489:5 in 'parse_equality'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:488:5 in 'parse_and'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:487:5 in 'parse_or'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:440:7 in 'parse_range'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:413:7 in 'parse_question_colon'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:304:7 in 'parse_op_assign'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:300:5 in 'parse_op_assign'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:236:7 in 'parse_expression'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:113:7 in 'parse_multi_assign'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:102:9 in 'parse_expressions_internal'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:3784:7 in 'parse_expressions'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:73:21 in 'parse'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:16:7 in 'parse'","/home/lesell_b/Projects/opensource/scry/src/scry/completion/method_db.cr:27:11 in 'generate'","/home/lesell_b/Projects/opensource/scry/src/scry/workspace.cr:27:7 in 'put_file'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:128:7 in 'dispatchNotification'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:39:7 in 'dispatch'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:23:19 in 'start'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:40:1 in '__crystal_main'","/usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'","/usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'","/usr/lib/crystal/crystal/main.cr:101:7 in 'main'","/usr/lib/crystal/crystal/main.cr:135:3 in 'main'","__libc_start_main","_start","???"]}}
D, [2018-03-10 02:15:45 -08:00 #3622] DEBUG -- : Content-Length: 196
D, [2018-03-10 02:15:45 -08:00 #3622] DEBUG -- : 
D, [2018-03-10 02:15:45 -08:00 #3622] DEBUG -- : {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":8,"line":15},"textDocument":{"uri":"file:///home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr"}},"id":13}
D, [2018-03-10 02:15:45 -08:00 #3622] DEBUG -- : textDocument/completion
D, [2018-03-10 02:15:45 -08:00 #3622] DEBUG -- : Content SEND: Content-Length: 882

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Missing hash key: \"/home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr\"","data":["/usr/lib/crystal/hash.cr:0:9 in 'fetch'","/usr/lib/crystal/hash.cr:62:5 in '[]'","/home/lesell_b/Projects/opensource/scry/src/scry/workspace.cr:44:7 in 'get_file'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:58:36 in 'dispatchRequest'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:33:9 in 'dispatch'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:23:19 in 'start'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:40:1 in '__crystal_main'","/usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'","/usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'","/usr/lib/crystal/crystal/main.cr:101:7 in 'main'","/usr/lib/crystal/crystal/main.cr:135:3 in 'main'","__libc_start_main","_start","???"]}}
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : Content-Length: 358
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : 
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":null,"rangeLength":null,"text":"class Foo\n  def self.bar(io : IO)\n  end\nend\n\nclass Bar\n  def self.bla\n    3\n  end\n\n  def ljkh\n    2\n  end\nend\n\nBar.new"}],"textDocument":{"uri":"file:///home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr","version":1}}}
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : textDocument/didChange
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : Content SEND: Content-Length: 891

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Missing hash key: \"/home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr\"","data":["/usr/lib/crystal/hash.cr:0:9 in 'fetch'","/usr/lib/crystal/hash.cr:62:5 in '[]'","/home/lesell_b/Projects/opensource/scry/src/scry/workspace.cr:33:17 in 'update_file'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:138:7 in 'dispatchNotification'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:39:7 in 'dispatch'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:23:19 in 'start'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:40:1 in '__crystal_main'","/usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'","/usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'","/usr/lib/crystal/crystal/main.cr:101:7 in 'main'","/usr/lib/crystal/crystal/main.cr:135:3 in 'main'","__libc_start_main","_start","???"]}}
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : Content-Length: 196
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : 
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":7,"line":15},"textDocument":{"uri":"file:///home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr"}},"id":14}
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : textDocument/completion
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : Content SEND: Content-Length: 882

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Missing hash key: \"/home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr\"","data":["/usr/lib/crystal/hash.cr:0:9 in 'fetch'","/usr/lib/crystal/hash.cr:62:5 in '[]'","/home/lesell_b/Projects/opensource/scry/src/scry/workspace.cr:44:7 in 'get_file'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:58:36 in 'dispatchRequest'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:33:9 in 'dispatch'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:23:19 in 'start'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:40:1 in '__crystal_main'","/usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'","/usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'","/usr/lib/crystal/crystal/main.cr:101:7 in 'main'","/usr/lib/crystal/crystal/main.cr:135:3 in 'main'","__libc_start_main","_start","???"]}}
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : Content-Length: 359
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : 
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":null,"rangeLength":null,"text":"class Foo\n  def self.bar(io : IO)\n  end\nend\n\nclass Bar\n  def self.bla\n    3\n  end\n\n  def ljkh\n    2\n  end\nend\n\nBar.new."}],"textDocument":{"uri":"file:///home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr","version":2}}}
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : textDocument/didChange
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : Content SEND: Content-Length: 891

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Missing hash key: \"/home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr\"","data":["/usr/lib/crystal/hash.cr:0:9 in 'fetch'","/usr/lib/crystal/hash.cr:62:5 in '[]'","/home/lesell_b/Projects/opensource/scry/src/scry/workspace.cr:33:17 in 'update_file'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:138:7 in 'dispatchNotification'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:39:7 in 'dispatch'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:23:19 in 'start'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:40:1 in '__crystal_main'","/usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'","/usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'","/usr/lib/crystal/crystal/main.cr:101:7 in 'main'","/usr/lib/crystal/crystal/main.cr:135:3 in 'main'","__libc_start_main","_start","???"]}}
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : Content-Length: 196
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : 
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":8,"line":15},"textDocument":{"uri":"file:///home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr"}},"id":15}
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : textDocument/completion
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : Content SEND: Content-Length: 882

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Missing hash key: \"/home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr\"","data":["/usr/lib/crystal/hash.cr:0:9 in 'fetch'","/usr/lib/crystal/hash.cr:62:5 in '[]'","/home/lesell_b/Projects/opensource/scry/src/scry/workspace.cr:44:7 in 'get_file'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:58:36 in 'dispatchRequest'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:33:9 in 'dispatch'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:23:19 in 'start'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:40:1 in '__crystal_main'","/usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'","/usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'","/usr/lib/crystal/crystal/main.cr:101:7 in 'main'","/usr/lib/crystal/crystal/main.cr:135:3 in 'main'","__libc_start_main","_start","???"]}}
D, [2018-03-10 02:15:47 -08:00 #3622] DEBUG -- : Content-Length: 148
D, [2018-03-10 02:15:47 -08:00 #3622] DEBUG -- : 
D, [2018-03-10 02:15:47 -08:00 #3622] DEBUG -- : {"jsonrpc":"2.0","method":"textDocument/didSave","params":{"textDocument":{"uri":"file:///home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr"}}}
D, [2018-03-10 02:15:47 -08:00 #3622] DEBUG -- : textDocument/didSave
D, [2018-03-10 02:15:48 -08:00 #3622] DEBUG -- : 
W, [2018-03-10 02:15:48 -08:00 #3622]  WARN -- : Connection with client lost
D, [2018-03-10 02:15:48 -08:00 #3622] DEBUG -- : Content SEND: Content-Length: 872

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Content-Length header is required. Ex: Content-Length: 132\\r\\n","data":["/home/lesell_b/Projects/opensource/scry/src/scry/headers.cr:25:17 in 'content_length'","/home/lesell_b/Projects/opensource/scry/src/scry/request.cr:45:7 in 'content_length'","/home/lesell_b/Projects/opensource/scry/src/scry/request.cr:39:18 in 'read_content'","/home/lesell_b/Projects/opensource/scry/src/scry/request.cr:14:7 in 'read'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:21:19 in 'start'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:40:1 in '__crystal_main'","/usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'","/usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'","/usr/lib/crystal/crystal/main.cr:101:7 in 'main'","/usr/lib/crystal/crystal/main.cr:135:3 in 'main'","__libc_start_main","_start","???"]}}
E, [2018-03-10 02:15:48 -08:00 #3622] ERROR -- : Error writing file: Broken pipe
/usr/lib/crystal/io/file_descriptor.cr:72:11 in 'unbuffered_write'
/usr/lib/crystal/io/buffered.cr:120:9 in 'write'
/usr/lib/crystal/io.cr:487:7 in 'write_utf8'
/usr/lib/crystal/string.cr:4139:5 in 'to_s'
/usr/lib/crystal/io.cr:192:5 in '<<'
/home/lesell_b/Projects/opensource/scry/src/scry/response.cr:24:7 in 'log_and_write'
/home/lesell_b/Projects/opensource/scry/src/scry/response.cr:17:9 in 'write'
/home/lesell_b/Projects/opensource/scry/src/scry.cr:28:9 in 'start'
/home/lesell_b/Projects/opensource/scry/src/scry.cr:40:1 in '__crystal_main'
/usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'
/usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'
/usr/lib/crystal/crystal/main.cr:101:7 in 'main'
/usr/lib/crystal/crystal/main.cr:135:3 in 'main'
__libc_start_main
_start
???

This seems to happen when the opened file is not valid on first load. So when Scry receives the textDocument/didOpen request, it tries to build the MethodDB. At this point, as the file is not valid, the method failes, and doesn't add the file in the list of opened file in the workspace, and subsequent operations on this file (even if it fixes the syntax (or other) error, the file will not be added to the workspace again.

Maybe we should add a default empty MethodDB if the initial generation fails?

@laginha87
Copy link
Contributor

There are a couple of issues that are causing this:

  1. Generating the method db if one of the files required by the one you opened is invalid it breaks :(. The generation uses the crystal parser we should catch it there and ignore that file. (This throws the error missing hash key)
  2. When you add requires in the current file its dependancies aren't updated. Same for deleting requires. (This is what throws the Couldn't find type error )
  3. When you create a new file it also isn't in the dependancies graph which might also throw the error missing hash key.

Does this make sense? or did you have any other issues that doesn't seem like its caused by what I described?

These can all be worked on separately so I'm going to create an issue for each, and when those are solved we can come to this one, sounds good?

@laginha87
Copy link
Contributor

Created #60 and #61 . I think #61 might tackle both issues 2 and 3 that I described above.

@faustinoaq
Copy link
Member

I think #92 fixes this 😅

Crystal Tools automation moved this from To do to Done May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Crystal Tools
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants