rest-nvim / rest.nvim

A fast Neovim http client written in Lua
GNU General Public License v3.0
1.61k stars 142 forks source link

Calling REST endpoint with debugging breakpoint causes Neovim to become unresponsive #323

Closed simanga-dev closed 2 months ago

simanga-dev commented 7 months ago

I have setup a simple fast API demo project to reproduce this https://github.com/h3ndry/rest-nvim-test

Neovim Version

NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1692716794

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

Run :checkhealth for more info

Rest config

return {
  {
    'vhyrro/luarocks.nvim',
    config = function()
      require('luarocks').setup {}
    end,
  },
  {
    'rest-nvim/rest.nvim',
    ft = 'http',
    opts = {
      encode_url = false,
      keybinds = {
        {
          '<localleader>rr',
          '<cmd>Rest run<cr>',
          'Run request under the cursor',
        },
        {
          '<localleader>rl',
          '<cmd>Rest run last<cr>',
          'Re-run latest request',
        },
      },
    },
    dependencies = { 'luarocks.nvim' },
    config = function(_, opts)
      require('rest-nvim').setup(opts)
    end,
  },
}

python debug config

    require('dap-python').setup '/home/hendry/.virtualenvs/debugpy/bin/python'
    dap.configurations.lua = {
      {
        type = 'nlua',
        request = 'attach',
        name = 'Attach to running Neovim instance',
      },
    }
    dap.adapters.nlua = function(callback, config)
      callback { type = 'server', host = config.host or '127.0.0.1', port = config.port or 8086 }
    end
  end,

Steps to reproduce

  1. Add a breakpoint inside the function to be called
  2. start your debug server or debug the file using the nvim python debug
  3. Call the endpoint you are debugging using REST.NVIM

I have tested using the old version and curl, all seems to work except when using this plugin

Ajetski commented 6 months ago

I have reproduced this issue (its not specific to fast-api/python). The http call is blocking the UI thread. It should be possible to spawn an async job/task for that http call to fix this.

jonathan-elize commented 6 months ago

Yes I can confirm on the UI freezing while the call goes on. Hoping this can get fixed. I poked through the source code and saw there was some logic to use nvim-nio to. But this doesn't seem to help either.

boltlessengineer commented 2 months ago

The #373 is closed now. Closing this too as a related issue. Feel free to reopen this if it still happens.

ejrichards commented 2 months ago

@boltlessengineer #373 was closed as a duplicate of this issue, it was not resolved

boltlessengineer commented 2 months ago

@ejrichards I think I misunderstood the relationship between the issues. Both are resolved now from v3 release.

ejrichards commented 2 months ago

Got it, I was having a hanging issue, but I think it might be related to Windows rather than this ticket. Will post a new one if I can get more information / confirm it.