arduino-language-server icon indicating copy to clipboard operation
arduino-language-server copied to clipboard

Error: jsonrpc2: connection is closed

Open svenefftinge opened this issue 6 years ago • 8 comments

Opening an .ino file and then doing some edits. Specifically typing:

const char* string = "foo%test";

eventually results in: jsonrpc2: connection is closed after which nothing works anymore.

See also https://github.com/arduino/arduino-pro-ide/issues/154

svenefftinge avatar Nov 28 '19 08:11 svenefftinge

The underlying clangd process crashes. I do not yet know why. I've debugged into the LS and I can confirm this notification is failing, for instance: https://github.com/bcmi-labs/arduino-language-server/blob/209f1719f13b9343cb9ef074ad39fc1e1bf9fedc/handler/handler.go#L125

See the screencast as "proof": screencast 2019-12-11 17-01-52

kittaakos avatar Dec 11 '19 16:12 kittaakos

I can see the following in the inols-clangd-err.log log file:

I[09:09:51.474] <-- initialize(0)
I[09:09:51.475] --> reply:initialize(0) 0 ms
I[09:09:51.627] <-- initialized
I[09:09:51.627] unhandled notification initialized
I[09:09:52.221] <-- textDocument/didOpen
I[09:09:52.221] Updating file /private/var/folders/k3/d2fkvv1j16v3_rz93k7f74180000gn/T/ino2cpp-772306105/sketch_december11b.ino.cpp with command [/private/var/folders/k3/d2fkvv1j16v3_rz93k7f74180000gn/T/ino2cpp-772306105] /Users/akos.kitta/git/arduino-editor/arduino-ide-extension/build/clang-tool --target=avr -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Users/akos.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino -I/Users/akos.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/variants/standard -I/Users/akos.kitta/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/avr/include -I/Users/akos.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/libraries/EEPROM/src -I/Users/akos.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/libraries/HID/src -I/Users/akos.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/libraries/SPI/src -I/Users/akos.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/libraries/SoftwareSerial/src -I/Users/akos.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/libraries/Wire/src -I/Users/akos.kitta/Documents/Arduino/libraries/Firebase_Arduino_based_on_WiFi101/src -I/Users/akos.kitta/Documents/Arduino/libraries/IoTtweet/src -I/Users/akos.kitta/Documents/Arduino/libraries/IoTtweetESP32/src -I/Users/akos.kitta/Documents/Arduino/libraries/WiFi101/src /private/var/folders/k3/d2fkvv1j16v3_rz93k7f74180000gn/T/ino2cpp-772306105/sketch_december11b.ino.cpp -resource-dir=/Users/akos.kitta/git/arduino-editor/arduino-ide-extension/build/../lib/clang/8.0.1
I[09:09:52.297] Dropped diagnostic outside main file: /Users/akos.kitta/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/avr/include/stdlib.h: 'stddef.h' file not found
I[09:09:52.302] --> textDocument/publishDiagnostics
I[09:09:52.565] <-- textDocument/codeAction(1)
I[09:09:52.565] --> reply:textDocument/codeAction(1) 0 ms

Can this error cause the clangd crash, @spoenemann? The file /Users/akos.kitta/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/avr/include/stdlib.h exists by the way.

Update: However, the referenced file #include <stddef.h> from the stdlib.h does not exist, at least in the same include folder:

% pwd
/Users/akos.kitta/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/avr/include
akos.kitta@Akoss-MacBook-Pro include % ls -al
total 424
drwxr-xr-x   23 akos.kitta  staff    736 Dec  9 17:47 .
drwxr-xr-x    5 akos.kitta  staff    160 Dec  9 17:46 ..
-rw-r--r--    1 akos.kitta  staff   2559 Dec  9 17:47 alloca.h
-rw-r--r--    1 akos.kitta  staff   3831 Dec  9 17:47 assert.h
drwxr-xr-x  329 akos.kitta  staff  10528 Dec  9 17:47 avr
drwxr-xr-x    5 akos.kitta  staff    160 Dec  9 17:47 compat
-rw-r--r--    1 akos.kitta  staff   5309 Dec  9 17:47 ctype.h
-rw-r--r--    1 akos.kitta  staff   4587 Dec  9 17:47 errno.h
-rw-r--r--    1 akos.kitta  staff     23 Dec  9 17:47 fcntl.h
-rw-r--r--    1 akos.kitta  staff  15788 Dec  9 17:47 inttypes.h
-rw-r--r--    1 akos.kitta  staff    363 Dec  9 17:47 locale.h
-rw-r--r--    1 akos.kitta  staff  15620 Dec  9 17:47 math.h
-rw-r--r--    1 akos.kitta  staff   5132 Dec  9 17:47 setjmp.h
-rw-r--r--    1 akos.kitta  staff    611 Dec  9 17:47 signal.h
-rw-r--r--    1 akos.kitta  staff   2022 Dec  9 17:47 stdfix-avrlibc.h
-rw-r--r--    1 akos.kitta  staff  16717 Dec  9 17:47 stdint.h
-rw-r--r--    1 akos.kitta  staff  36387 Dec  9 17:47 stdio.h
-rw-r--r--    1 akos.kitta  staff  25152 Dec  9 17:47 stdlib.h
-rw-r--r--    1 akos.kitta  staff  24461 Dec  9 17:47 string.h
drwxr-xr-x    3 akos.kitta  staff     96 Dec  9 17:47 sys
-rw-r--r--    1 akos.kitta  staff  18643 Dec  9 17:47 time.h
-rw-r--r--    1 akos.kitta  staff    183 Dec  9 17:47 unistd.h
drwxr-xr-x   11 akos.kitta  staff    352 Dec  9 17:47 util

kittaakos avatar Dec 12 '19 08:12 kittaakos

This is also suspicious;

2019/12/12 09:37:41 Timeout exceeded while waiting for a reply from clangd: textDocument/codeAction
2019/12/12 09:37:41 From stdio: textDocument/didSave
2019/12/12 09:37:41 Please restart the language server.
2019/12/12 09:37:41 From stdio: workspace/didChangeWatchedFiles

kittaakos avatar Dec 12 '19 08:12 kittaakos

At the very least, the language server should automatically restart when the connection is closed.

spoenemann avatar Dec 12 '19 09:12 spoenemann

the language server should automatically restart

What do you mean by "should restart", do we have such logic in the LS itself or Arduino Pro IDE, or maybe Theia? Or have you mentioned it as a missing feature?

kittaakos avatar Dec 12 '19 10:12 kittaakos

Or have you mentioned it as a missing feature?

Related: https://github.com/eclipse-theia/theia/issues/6739

kittaakos avatar Dec 12 '19 12:12 kittaakos

https://github.com/eclipse-theia/theia/issues/6308

spoenemann avatar Dec 12 '19 13:12 spoenemann

Wow, thanks! So, it's a missing feature in Theia.

kittaakos avatar Dec 12 '19 13:12 kittaakos