You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NVIM v0.10.0-dev-2632+ge3bd04f2a-dirty
Build type: RelWithDebInfo
LuaJIT 2.1.1710088188
Run "nvim -V1 -v" for more info
Describe the bug
When table.sort is called inside a nio task (async context) and a nio async function is called in the compare function, I get attempt to yield across C-call boundary error.
Is there an easy way you can think of to avoid this problem?
I'm very aware this is a VERY niche usecase but I wanted to at least bring this up to the discussion.
I can easily use vim.loop.fs_stat instead of nio.uv.fs_stat inside the compare function. TBH I think vim.loop solution is faster in this case since it does not need to send data back and forth.
I don't consider this a bug but hopefully comes up in the search engine if someone else has also been stuck with the same problem.
If you can think of other workaround ideas, I'm also happy to hear them.
Error executing luv callback:
.../.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:95: Async task failed without callback: The coroutine failed with this message:
.../.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:198: attempt to yield across C-call boundary
stack traceback:
[C]: in function 'sort'
[string ":source (no file)"]:84: in function <[string ":source (no file)"]:63>
stack traceback:
[C]: in function 'error'
.../.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:95: in function 'close_task'
.../.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:117: in function 'cb'
.../.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:183: in function <.../.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:182>
The text was updated successfully, but these errors were encountered:
Yeah this makes sense as the sorting function is called from C, which means you can't yield from a coroutine. I think the best way to work around this would be to pre-compute the sortkeys (i.e. nio.uv.fs_stat(tostring(value))) and just look them up in the sort function. This also has the added benefit of not running the stat function multiple times for the same path and also not blocking the main thread as you would by using vim.loop
NeoVim Version
Describe the bug
When
table.sort
is called inside a nio task (async context) and a nio async function is called in the compare function, I getattempt to yield across C-call boundary
error.Is there an easy way you can think of to avoid this problem?
I'm very aware this is a VERY niche usecase but I wanted to at least bring this up to the discussion.
I can easily use
vim.loop.fs_stat
instead ofnio.uv.fs_stat
inside the compare function. TBH I thinkvim.loop
solution is faster in this case since it does not need to send data back and forth.I don't consider this a bug but hopefully comes up in the search engine if someone else has also been stuck with the same problem.
If you can think of other workaround ideas, I'm also happy to hear them.
To Reproduce
Logs
The text was updated successfully, but these errors were encountered: