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

Error when calling NodeInspectToggleBreakpoint #5

Open
AdrienLemaire opened this issue May 27, 2020 · 8 comments
Open

Error when calling NodeInspectToggleBreakpoint #5

AdrienLemaire opened this issue May 27, 2020 · 8 comments
Labels
enhancement New feature or request

Comments

@AdrienLemaire
Copy link

AdrienLemaire commented May 27, 2020

:NodeInspectRun

Error detected while processing function nodeinspect#NodeInspectRun[13]..<SNR>203_NodeInspectStart:
line   75:
E716: Key not present in Dictionary: watches
E116: Invalid arguments for function keys
E15: Invalid expression: keys(s:session["watches"])

:NodeInspectToggleBreakpoint

Error detected while processing function OnNodeNvimMessage[1]..OnNodeMessage[21]..<SNR>198_breakpointResolved[23]..<SNR>198_addBrkptSign:
line    2:
E155: Unknown sign: visbkpt

While I'm getting the errors and the signs aren't showing up on the vim window, it looks like the breakpoint is still set, and I can use the terminal buffer to explore variables through repl.

Wondering if this issue occurs because of working with typescript files instead of js ones.

Using nodemon with the following nodemon.json config:

{
  "watch": ["src"],
  "ext": "ts",
  "ignore": ["src/**/*.spec.ts"],
  "exec": "node --inspect=0.0.0.0:9229 --require ts-node/register ./src/index.ts",
  "verbose": true
}
@eliba2
Copy link
Owner

eliba2 commented May 27, 2020

It could be ts, though In a glance I suspect the problem is in the session file (which stores the session between vim instances) or compatibility.
Can you post your session file (its in ~/.vim/plugged/vim-node-inspect/vim-node-session.json) and version (:version output)?
cheers

@AdrienLemaire
Copy link
Author

@eliba2 thanks for the quick reply

vim-node-session

{"watches": {}, "breakpoints": {"/home/dori/Projects/Work/project/api_server/src/resolvers.ts": {"8": 5}}}

or

{"watches": {}, "breakpoints": {}}

neovim :version

NVIM v0.4.3
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-
prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim/src/b
uild/config -I/build/neovim/src/neovim-0.4.3/src -I/usr/include -I/build/neovim/src/build/src/nvim/auto -I/build/neovim/src/build/include
Compiled by builduser

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

node.js debugger Version from breakpoint:

>> version
8.1.307.31-node.33 

Other bug: executing c in the terminal buffer doesn't exit the shell. I can confirm that the node process continued as expected, and if I try executing other commands afterwards, I get an error

>> c
>> c
Uncaught Error: Can only perform operation while paused. - undefined
    at _pending.<computed> (/home/dori/.vim/plugged/vim-node-inspect/node-inspect/lib/internal/inspect_client.js:250:27)
    at Client._handleChunk (/home/dori/.vim/plugged/vim-node-inspect/node-inspect/lib/internal/inspect_client.js:215:11)
    at Socket.emit (events.js:315:20)
    at Socket.EventEmitter.emit (domain.js:485:12)
    at addChunk (_stream_readable.js:302:12)
    at readableAddChunk (_stream_readable.js:278:9)
    at Socket.Readable.push (_stream_readable.js:217:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:186:23) {
  code: -32000
}

I'd expect the terminal prompt to disappear after executing the first c

@eliba2
Copy link
Owner

eliba2 commented May 28, 2020

the session and the :version output looks ok; I'll need to run a ts setup to try this.
About the second issue, repl commands were not going through the plugin hence the state is not reflected in the editor. I've fixed that in the latest.
cheers

@AdrienLemaire
Copy link
Author

Yes, I could see the vim marks on js files, so definitely something to do with ts. Looking forward to your fix :)
Your project is awesome, totally underrated 👍

@eliba2
Copy link
Owner

eliba2 commented May 29, 2020

Thanks,
Yes I can confirm it is because of ts; the breakpoints are set on a js file which needs to be resolved to a ts location (probably using sourcemaps). It requires additional effort; once I'll estimate that I will set a resolution for this.

@eliba2 eliba2 added the enhancement New feature or request label May 29, 2020
@cincodenada
Copy link
Contributor

cincodenada commented Feb 12, 2021

I'm getting a message similar to the first message noted above. The error appears to be in the access to "watches" is in NodeInspectStart(). I successfully squelched the error by wrapping it in a has_key check, but that may be treating the symptoms rather than the problem, if s:session["watches"] should always be set and isn't for some reason. My session file looks the same as the empty one posted above.

Here's my squelching patch:

 in vim-node-inspect/ on master
› git diff -u
diff --git a/autoload/nodeinspect.vim b/autoload/nodeinspect.vim
index 72c28ea..122710d 100644
--- a/autoload/nodeinspect.vim
+++ b/autoload/nodeinspect.vim
@@ -599,10 +599,11 @@ function! s:NodeInspectStart()
                endif
        endif
        " redraw the watch window; draws any watches added from the session
-       for watch in keys(s:session["watches"])
-               call nodeinspect#watches#AddBulk(s:session["watches"])
-       endfor
-
+       if has_key(s:session, "watches")
+           for watch in keys(s:session["watches"])
+                   call nodeinspect#watches#AddBulk(s:session["watches"])
+           endfor
+       endif
 endfunction

@cincodenada
Copy link
Contributor

Hmm, I also get a similar message to above ("Unknown sign: vis" for me) but I am not using typescript at all, although there may be some babeling going on, I'm not sure what my test runner is getting up to to be honest.

@eliba2
Copy link
Owner

eliba2 commented Feb 13, 2021

hi,
it seems nodeinspect#OnNodeInspectEnter autocmd is not called for some reason. It sets up the watches and icons upon vim startup (see last line in plugin/nodeinspect.vim).
It seems the plugin/nodeinspect.vim file is processed (as you wouldn't able to call any command if it wasn't), just the autocmd is not. The possible reason for it is a presence of another plugin which overrides the VimEnter command. E.g., if a plugin defines a VimEnter autocmd command such as
autocmd VimEnter * call myfunc1()
and then another plugin adds similar call with an ! at the end:
autocmd! VimEnter * call myfunc2()
The last call will remove the first autocmd call. This hypotheses can be checked by running :autocmd VimEnter and checking if the call to nodeinspect#OnNodeInspectEnter is there. If that's the case (and also if its not) its better to wrap the autocmd command with an augroup to avoid this. I'll add it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants