Open roginfarrer opened 1 year ago
Unfortunately I can't reproduce. I'm not sure if this is a treesitter issue or an issue with the subprocess loading. Can you try reinstall your treesitter parsers? If that doesn't work, can you comment out this line https://github.com/nvim-neotest/neotest/blob/b06b0ccbddc61acfe781689da969d2e0117b3dfe/lua/neotest/client/init.lua#L373 to disable the subprocess starting and see if the behaviour is the same?
That does seem to help! Both "nearest test" and the "file tests" kick-off on the first try.
Reinstalling the parsers didn't have an effect, but commenting out that line did.
Is this happening for all jest projects? Can you point to a public repo I can test?
Right now I believe the issues lies with plenary's filetype detection
https://github.com/nvim-neotest/neotest/blob/b06b0ccbddc61acfe781689da969d2e0117b3dfe/lua/neotest/lib/treesitter/init.lua#L115
but I'm not sure what would cause the issue. If you can't provide a public repo to reproduce, the only thing I can suggest is manually logging such as after that line adding logger.info(file_path, "detected as", ft)
and seeing if the values are valid
I have a similar issue on fedora. I have the same setup (via dotfiles repo) on my Mac as well. For some reason on Mac it works fine but on linux it works only if I comment the following line you mentioned in the other comment:
lib.subprocess.init()
Stacktrace from neotest.log
:
ERROR | 2023-03-16T18:54:42Z+0100 | ...te/pack/packer/start/neotest/lua/neotest/client/init.lua:310 | Couldn't find positions in path /home/luke/projects/diva/store-bridge/dist/__tests__/server.js.map ...0.8.3/share/nvim/runtime/lua/vim/treesitter/language.lua:23: '' is not a valid language name
stack traceback:
[C]: in function 'error'
...0.8.3/share/nvim/runtime/lua/vim/treesitter/language.lua:23: in function 'require_language'
...r/neovim/0.8.3/share/nvim/runtime/lua/vim/treesitter.lua:116: in function 'get_string_parser'
...packer/start/neotest/lua/neotest/lib/treesitter/init.lua:118: in function 'get_parse_root'
...packer/start/neotest/lua/neotest/lib/treesitter/init.lua:159: in function 'parse_positions_from_string'
...packer/start/neotest/lua/neotest/lib/treesitter/init.lua:206: in function 'discover_positions'
...te/pack/packer/start/neotest/lua/neotest/client/init.lua:301: in function <...te/pack/packer/start/neotest/lua/neotest/client/init.lua:265>
[C]: in function 'xpcall'
...te/pack/packer/start/neotest/lua/neotest/client/init.lua:265: in function '_update_positions'
...te/pack/packer/start/neotest/lua/neotest/client/init.lua:318: in function <...te/pack/packer/start/neotest/lua/neotest/client/init.lua:316>
Are there any other details I could provide?
Can you enable debug logging, add the log line as I detailed here https://github.com/nvim-neotest/neotest/issues/207#issuecomment-1447823605 and provide the full log?
So I'm running on arch linux and for me it just freezes completely, no lag, but commenting out the lib.subprocess.init
line works for me as well. I added the log line, but it freezes before it can log anything. Doesn't matter how long I wait, only way out is to kill the neovim process. My config is at https://github.com/bjornsnoen/dotfiles/tree/master/nvim for reproducing.
I've been trying to create a solid set of steps to reproduce, but this is the best I've got.
npx create-next-app
all defaults, default app name is my-appnpm i vitest
inside the new appsrc/tests/something.test.ts
import { test } from "vitest"; test("something", () => {});
scripts.test: "vitest"
to package.jsonError executing vim.schedule lua callback: ...e/bjorn/.local/share/nvim/lazy/neotest/lua/nio/tasks.lua:95: Async task failed without callback: The coroutine failed with this message:
...e/bjorn/.local/share/nvim/lazy/neotest/lua/nio/tasks.lua:95: Async task failed without callback: The coroutine failed with this message:
...vim/lazy/neotest/lua/neotest/consumers/state/tracker.lua:47: attempt to index local 'tree' (a nil value)
stack traceback:
...vim/lazy/neotest/lua/neotest/consumers/state/tracker.lua: in function 'is_test'
...vim/lazy/neotest/lua/neotest/consumers/state/tracker.lua:155: in function 'update_running'
...e/nvim/lazy/neotest/lua/neotest/consumers/state/init.lua:49: in function 'listener'
...are/nvim/lazy/neotest/lua/neotest/client/events/init.lua:51: in function <...are/nvim/lazy/neotest/lua/neotest/client/events/init.lua:47>
stack traceback:
[C]: in function 'error'
...e/bjorn/.local/share/nvim/lazy/neotest/lua/nio/tasks.lua:95: in function 'close_task'
...e/bjorn/.local/share/nvim/lazy/neotest/lua/nio/tasks.lua:117: in function 'step'
...e/bjorn/.local/share/nvim/lazy/neotest/lua/nio/tasks.lua:143: in function 'run'
...are/nvim/lazy/neotest/lua/neotest/client/events/init.lua:47: in function 'emit'
...hare/nvim/lazy/neotest/lua/neotest/client/state/init.lua:96: in function 'update_running'
...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:82: in function 'run_tree'
...al/share/nvim/lazy/neotest/lua/neotest/consumers/run.lua:72: in function 'func'
...e/bjorn/.local/share/nvim/lazy/neotest/lua/nio/tasks.lua:166: in function <...e/bjorn/.local/share/nvim/lazy/neotest/lua/nio/tasks.lua:165>
stack traceback:
[C]: in function 'error'
...e/bjorn/.local/share/nvim/lazy/neotest/lua/nio/tasks.lua:95: in function 'close_task'
...e/bjorn/.local/share/nvim/lazy/neotest/lua/nio/tasks.lua:117: in function 'cb'
...e/bjorn/.local/share/nvim/lazy/neotest/lua/nio/tasks.lua:179: in function <...e/bjorn/.local/share/nvim/lazy/neotest/lua/nio/tasks.lua:178>
Note that this fs path is now tainted somehow. If you rm the whole app directory and start over reusing the same app name, it will skip the error in step 6 and go straight to step 10. Again, commenting out the subrocess.init line does fix this. It also brings back the error in step 6 so it happens every time.
Hope this helps a bit!
Hello,
I've come across a similar issue, I guess (or just hesitate to create a new issue). Anyway, it happens frequently to me, but not every time. Apparently it's a concurrency issue. The error is the same as in the comment https://github.com/nvim-neotest/neotest/issues/207#issuecomment-1534357498, but the stack trace is slightly different, I guess the version of neotest is different, because it's been a year and a half since that time.
I'll post the stack trace if it makes sense
Error executing vim.schedule lua callback: ...ord/.local/share/nvim/plugged/nvim-nio/lua/nio/tasks.lua:100: Async task failed without callback: The coroutine failed with this message:
...ord/.local/share/nvim/plugged/nvim-nio/lua/nio/tasks.lua:100: Async task failed without callback: The coroutine failed with this message:
.../plugged/neotest/lua/neotest/consumers/state/tracker.lua:47: attempt to index local 'tree' (a nil value)
stack traceback:
.../plugged/neotest/lua/neotest/consumers/state/tracker.lua: in function 'is_test'
.../plugged/neotest/lua/neotest/consumers/state/tracker.lua:155: in function 'update_running'
...vim/plugged/neotest/lua/neotest/consumers/state/init.lua:49: in function 'listener'
.../nvim/plugged/neotest/lua/neotest/client/events/init.lua:51: in function <.../nvim/plugged/neotest/lua/neotest/client/events/init.lua:47>
stack traceback:
[C]: in function 'error'
...ord/.local/share/nvim/plugged/nvim-nio/lua/nio/tasks.lua:100: in function 'close_task'
...ord/.local/share/nvim/plugged/nvim-nio/lua/nio/tasks.lua:122: in function 'step'
...ord/.local/share/nvim/plugged/nvim-nio/lua/nio/tasks.lua:150: in function 'run'
.../nvim/plugged/neotest/lua/neotest/client/events/init.lua:47: in function 'emit'
...e/nvim/plugged/neotest/lua/neotest/client/state/init.lua:95: in function 'update_running'
...l/share/nvim/plugged/neotest/lua/neotest/client/init.lua:82: in function 'run_tree'
...share/nvim/plugged/neotest/lua/neotest/consumers/run.lua:85: in function 'func'
...ord/.local/share/nvim/plugged/nvim-nio/lua/nio/tasks.lua:173: in function <...ord/.local/share/nvim/plugged/nvim-nio/lua/nio/tasks.lua:172>
stack traceback:
[C]: in function 'error'
...ord/.local/share/nvim/plugged/nvim-nio/lua/nio/tasks.lua:100: in function 'close_task'
...ord/.local/share/nvim/plugged/nvim-nio/lua/nio/tasks.lua:122: in function 'cb'
...ord/.local/share/nvim/plugged/nvim-nio/lua/nio/tasks.lua:188: in function 'waiter'
...d/.local/share/nvim/plugged/nvim-nio/lua/nio/control.lua:57: in function 'set'
...lord/.local/share/nvim/plugged/nvim-nio/lua/nio/init.lua:109: in function 'cb'
...ord/.local/share/nvim/plugged/nvim-nio/lua/nio/tasks.lua:105: in function 'close_task'
...ord/.local/share/nvim/plugged/nvim-nio/lua/nio/tasks.lua:127: in function 'cb'
...ord/.local/share/nvim/plugged/nvim-nio/lua/nio/tasks.lua:188: in function 'waiter'
...d/.local/share/nvim/plugged/nvim-nio/lua/nio/control.lua:57: in function 'set'
...lord/.local/share/nvim/plugged/nvim-nio/lua/nio/init.lua:151: in function 'cb'
...ord/.local/share/nvim/plugged/nvim-nio/lua/nio/tasks.lua:105: in function 'close_task'
...ord/.local/share/nvim/plugged/nvim-nio/lua/nio/tasks.lua:127: in function 'cb'
...ord/.local/share/nvim/plugged/nvim-nio/lua/nio/tasks.lua:188: in function 'handler'
...home/wantlord/Apps/neovim/runtime/lua/vim/lsp/client.lua:687: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
Given that, I popped out the debugger for Neovim plugins and found that StateTracker:update_running
runs sometimes before StateTracker:update_positions
. Therefore the field positions
is nil. So, I did this:
diff --git a/lua/neotest/consumers/state/init.lua b/lua/neotest/consumers/state/init.lua
index c9e48ee..eeb90e9 100644
--- a/lua/neotest/consumers/state/init.lua
+++ b/lua/neotest/consumers/state/init.lua
@@ -33,10 +33,12 @@ local function init(client)
for _, buf in ipairs(nio.api.nvim_list_bufs()) do
tracker:register_buffer(buf)
end
+ local event = nio.control.event()
nio.run(function()
xpcall(update_positions, function(msg)
logger.error("Error in state consumer", debug.traceback(msg, 2))
end)
+ event.set()
end)
client.listeners.discover_positions = function(adapter_id)
if not tracker:adapter_state(adapter_id) then
@@ -46,7 +48,7 @@ local function init(client)
end
client.listeners.run = function(adapter_id, _, position_ids)
- tracker:update_running(adapter_id, position_ids)
+ tracker:update_running(adapter_id, position_ids, event)
end
client.listeners.results = function(adapter_id, results)
diff --git a/lua/neotest/consumers/state/tracker.lua b/lua/neotest/consumers/state/tracker.lua
index 06a8a3f..4d7989c 100644
--- a/lua/neotest/consumers/state/tracker.lua
+++ b/lua/neotest/consumers/state/tracker.lua
@@ -147,7 +147,8 @@ function StateTracker:register_buffer(buffer)
self.path_buffers[path] = buffer
end
-function StateTracker:update_running(adapter_id, position_ids)
+function StateTracker:update_running(adapter_id, position_ids, event)
+ event.wait()
local state = self:adapter_state(adapter_id)
local running = state.running
local tree = state.positions
I doubt that it can be a proper fix, because it might break the design view of the author. However, it does the work just fine.
If you give me an insight, I'm happy to make a proper fix.
New issue from this comment: https://github.com/nvim-neotest/neotest/issues/198#issuecomment-1431991497
NeoVim Version NVIM v0.9.0-dev-3545+g6c39edaa7-dirty Build type: Release LuaJIT 2.1.0-beta3
Describe the bug When I run
test_file
, I get hit with some lag in my editor, and eventually the lag recedes but no test has been run or feedback given. I hit it again, and sometimes I get nothing, sometimes I get "No test found", or sometimes the test runs.I tried setting
discovery.concurrent = 1
, but then I get this error:I also sometimes get this error:
To Reproduce Please provide a minimal
init.lua
to reproduce which can be run as the following:You can edit the following example file to include your adapters and other required setup.
Here's an example test:
Logs
Additional context
neotest-jest