Skip to content

Conversation

@ldelossa
Copy link
Contributor

Continually run into the following error when restarting a debugging session:

Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/diagnostic.lua:1458: Invalid buffer id: 22
stack traceback:
        [C]: in function 'nvim_exec_autocmds'
        /usr/share/nvim/runtime/lua/vim/diagnostic.lua:1458: in function 'reset'
        /home/louis/.config/nvim/after/nvim-dap/lua/dap/session.lua:1399: in function 'close'
        /home/louis/.config/nvim/after/nvim-dap/lua/dap/session.lua:703: in function 'callback'
        /home/louis/.config/nvim/after/nvim-dap/lua/dap/session.lua:958: in function </home/louis/.config/nvim/after/nvim-dap/lua/dap/session.lua:950>

Swapping the session close and the reset of the namespace in session.lua seems to fix the issue.

Signed-off-by: Louis DeLosSantos [email protected]

Continually run into the following error when restarting a debugging
session:

```
Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/diagnostic.lua:1458: Invalid buffer id: 22
stack traceback:
        [C]: in function 'nvim_exec_autocmds'
        /usr/share/nvim/runtime/lua/vim/diagnostic.lua:1458: in function 'reset'
        /home/louis/.config/nvim/after/nvim-dap/lua/dap/session.lua:1399: in function 'close'
        /home/louis/.config/nvim/after/nvim-dap/lua/dap/session.lua:703: in function 'callback'
        /home/louis/.config/nvim/after/nvim-dap/lua/dap/session.lua:958: in function </home/louis/.config/nvim/after/nvim-dap/lua/dap/session.lua:950>
```

Swapping the session close and the reset of the namespace in session.lua
seems to fix the issue.

Signed-off-by: Louis DeLosSantos <[email protected]>
@mfussenegger mfussenegger merged commit 68d9687 into mfussenegger:master Dec 12, 2022
@mfussenegger
Copy link
Owner

Thanks

@ldelossa ldelossa deleted the fix-invalid-buffer-id branch December 12, 2022 17:50
@edward-s
Copy link

Was this fixed? Im still getting the same error on restarting debugging session with the latest commit

Error executing vim.schedule lua callback: ...r/neovim/0.8.1/share/nvim/runtime/lua/vim/diagnostic.lua:1426: Invalid buffer id: 17
stack traceback:
        [C]: in function 'nvim_exec_autocmds'
        ...r/neovim/0.8.1/share/nvim/runtime/lua/vim/diagnostic.lua:1426: in function 'reset'
        ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:1398: in function 'close'
        ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:1563: in function 'callback'
        ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:1412: in function 'callback'
        ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:931: in function <...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:927>

@ldelossa
Copy link
Contributor Author

Sadly, I dont think this fixed it. The problem seems so intermittent for me that I just didn't see it for awhile after the change. But I ran into it again yesterday.

@mfussenegger
Copy link
Owner

I didn't really understand why it would fix the error, but seemed harmless enough to merge :)

I never saw this error myself and don't quite understand how it can happen. Some reproduction steps would be nice. This might even be a bug in neovim as I don't think diagnostic.reset should ever raise an error about invalid buffers if it's called without bufnr parameter.

@mfussenegger
Copy link
Owner

Just to be sure. You're both on neovim 0.8.1 stable, or later? There were some fixes in Neovim related to handling buffer wipeout in the diagnostic code

@ldelossa
Copy link
Contributor Author

Yup nvim-0.9.0.

@mfussenegger
Copy link
Owner

Looks like this is an issue with neovim not always clearing the internal diagnostic cache: neovim/neovim#21454

@ldelossa
Copy link
Contributor Author

Should the nvim-dap code get wrapped in pcall for now? AFAICT, the bug is trying to perform an action on an invalid buffer and it can be safely ignored?

@mfussenegger
Copy link
Owner

Should the nvim-dap code get wrapped in pcall for now? AFAICT, the bug is trying to perform an action on an invalid buffer and it can be safely ignored?

That thought crossed my mind as well, but once there are stale diagnostic entries other operations can fail too. E.g. if you're trying to use vim.diagnostic.setqflist it would probably raise an error as well.

The error should only happen if the BufWipeout event isn't triggered for a buffer where an exception breakpoint happened.

I have no idea why that would happen in your setups.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants