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

Neovim occasional hang/freeze #456

Closed e2fletcher closed 2 months ago

e2fletcher commented 2 months ago

Prerequisites

Neovim Version

v0.10.1

Operating system/version

Archlinux

Actual behavior

I have noticed that nvim crashes when opening certain http files, attached is an example.

Note that the credentials inside the file are fictitious.

@endpoint=https://4ru348ru3u.execute-api.us-east-1.amazonaws.com/prod
@api_key = I9UNROdeWE4324h23uh23h4s4SDXlTdp26ilCrfpV

# INFO: SHOPIFY SELLER credentials 
@api_version=2024-07
@store_domain=reiterjerf.myshopify.com
@access_token=shpua_bafcf17a94324k23j4k314b2d1032eda7

###
# INFO: SHOPIFY SELLER list webhooks
GET https://{{store_domain}}/admin/api/{{api_version}}/webhooks.json
X-Shopify-Access-Token: {{access_token}}
Content-Type: application/json

###
# @name Get product
GET https://{{store_domain}}/admin/api/{{api_version}}/products/8884175241459.json
X-Shopify-Access-Token: {{access_token}}
Content-Type: application/json

###
# @name register-seller
POST {{endpoint}}/register-seller
X-Api-Key: {{api_key}}
Content-Type: application/json

{
  "sellerId": "shopify#{{store_domain}}",
  "storeDomain": "{{store_domain}}",
  "accessToken": "{{access_token}}"
}

###
# @name catalog-sync
POST {{endpoint}}/catalog-sync
X-Api-Key: {{api_key}}
Content-Type: application/json

{
  "sellerId": "shopify#{{store_domain}}"
}

###
# @name products-graphql
POST https://{{store_domain}}/admin/api/{{api_version}}/graphql.json
X-Shopify-Access-Token: {{access_token}}
X-REQUEST-TYPE: GraphQL

query Products($first: Int!) {
  products(first: $first) {
    nodes {
      id
      title
      category {
        id
        name
      }
    }
  }
}

{
  "first": 250
}

###
# @prompt h
GET https://example.com
Authorization: {{h}}

Expected behavior

It should open immediately. I have tried with the kulala plugin and this behavior does not occur, so I rule out any additional configuration. I change absolutely nothing and configure it as it is.

Steps to reproduce

To open the file I just try to open it from command mode with :e example.http

Other information

No response

Repro (lazy.nvim)

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
    spec = {
        {
          lazy = false,
          "rest-nvim/rest.nvim"
        },
        {
            "nvim-treesitter/nvim-treesitter",
            build = ":TSUpdate",
            main = "nvim-treesitter.configs",
            opts = {
                ensure_installed = { "http" },
                sync_install = false,
                highlight = { enable = true },
                indent = { enable = true },
            },
        },
    },
})
e2fletcher commented 2 months ago

Perform a test in kulala with treesitter = true in the settings and it does not freeze, it loads the file at normal speed.

boltlessengineer commented 2 months ago

That’s strange, rest.nvim doesn’t have any autocmds registered to http filetype or BufEnter events. You mean neovim freeze on nvim -u repro.lua example.http?

Can you try with this config in repro.lua?

{
  lazy = false,
  “rest-nvim/rest.nvim”,
  opts = {
    _log_level = vim.log.levels.DEBUG,
  }
},
  1. Edit config like this from repro.lua file
  2. Open neovim with nvim -u repro.lua (this will create .repro/ folder for temporary clean plugin installation)
  3. Try :e example.http
  4. If neovim freeze, open .repro/state/nvim/rest-nvim.log in different terminal
e2fletcher commented 2 months ago

Failure to take this option opts = { _log_level = vim.log.levels.DEBUG, } For some reason exposes the following error message Lua module not found for config of rest.nvim. Please use aconfig()function instead

The repro.lua file I used

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
    spec = {
        {
            lazy = false,
            "rest-nvim/rest.nvim",
            opts = {
                _log_level = vim.log.levels.DEBUG,
            },
        },
        {
            "nvim-treesitter/nvim-treesitter",
            build = ":TSUpdate",
            main = "nvim-treesitter.configs",
            opts = {
                ensure_installed = { "http" },
                sync_install = false,
                highlight = { enable = true },
                indent = { enable = true },
            },
        },
    },
})

Removing the option and reproducing it in the example.http file results in the same blocking behavior.

boltlessengineer commented 2 months ago

Thats strange. What can you see when you initially run nvim -u repro.lua after removing the .repro/ folder? If lazy is doing its job, it should be like this: (screenshot took in the mid of initial plugins installation) IMG_1406

Can you try running nvim -u repro.lua (with opts removed) and then run :Lazy and :checkhealth? Also, do you have luarocks installed on your machine? If so, what version of it? (you can check with luarocks --version) That may break lazy.nvim to properly install plugins from luarocks (see https://github.com/folke/lazy.nvim/issues/1741)

e2fletcher commented 2 months ago

After executing nvim -u repro.lua example.http

Captura desde 2024-09-12 11-16-19

I generated the http file I used for this test with touch example.http, and it still crashes.

When executing :checkhealth


==============================================================================
lazy: require("lazy.health").check()

lazy.nvim ~
- {lazy.nvim} version `11.14.1`
- OK {git} `version 2.46.0`
- OK no existing packages found by other package managers
- OK packer_compiled.lua not found

luarocks ~
- checking `luarocks` installation
- you have some plugins that require `luarocks`:
    * `rest.nvim`
- OK {luarocks} `/usr/bin/luarocks 3.11.1`
- OK {lua5.1} `Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio`

==============================================================================
nvim: require("nvim.health").check()

Configuration ~
- WARNING Missing user config file: /home/ender/.repro//config/nvim/init.lua
  - ADVICE:
    - :help |config|

Runtime ~
- OK $VIMRUNTIME: /usr/share/nvim/runtime

Performance ~
- OK Build type: Release

Remote Plugins ~
- OK Up to date

terminal ~
- key_backspace (kbs) terminfo entry: `key_backspace=\177`
- key_dc (kdch1) terminfo entry: `key_dc=\E[3~`
- $TERM_PROGRAM="tmux"
- $COLORTERM="truecolor"

tmux ~
- OK escape-time: 40
- OK focus-events: on
- $TERM: tmux-256color

External Tools ~
- OK ripgrep 14.1.1 (/usr/bin/rg)

==============================================================================
nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~
- OK `tree-sitter` found 0.23.0 (12fb31826b8469cc7b9788e72bceee5af1cf0977) (parser generator, only needed for :TSInstallFromGrammar)
- OK `node` found v20.12.2 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  Version: cc (GCC) 14.2.1 20240910
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
  machine = "x86_64",
  release = "6.10.9-arch1-2",
  sysname = "Linux",
  version = "#1 SMP PREEMPT_DYNAMIC Tue, 10 Sep 2024 14:37:32 +0000"
} ~

Parser/Features         H L F I J
  - bash                ✓ ✓ ✓ . ✓
  - c                   ✓ ✓ ✓ ✓ ✓
  - http                ✓ . ✓ . ✓
  - lua                 ✓ ✓ ✓ ✓ ✓
  - markdown            ✓ . ✓ ✓ ✓
  - markdown_inline     ✓ . . . ✓
  - python              ✓ ✓ ✓ ✓ ✓
  - query               ✓ ✓ ✓ ✓ ✓
  - vim                 ✓ ✓ ✓ . ✓
  - vimdoc              ✓ . . . ✓

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang} ~

==============================================================================
provider.clipboard: require("provider.clipboard.health").check()

Clipboard (optional) ~
- OK Clipboard tool found: xsel

==============================================================================
provider.node: require("provider.node.health").check()

Node.js provider (optional) ~
- Node.js: v20.12.2

- WARNING Missing "neovim" npm (or yarn, pnpm) package.
  - ADVICE:
    - Run in shell: npm install -g neovim
    - Run in shell (if you use yarn): yarn global add neovim
    - Run in shell (if you use pnpm): pnpm install -g neovim
    - You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim

==============================================================================
provider.perl: require("provider.perl.health").check()

Perl provider (optional) ~
- WARNING "Neovim::Ext" cpan module is not installed
  - ADVICE:
    - See :help |provider-perl| for more information.
    - You may disable this provider (and warning) by adding `let g:loaded_perl_provider = 0` to your init.vim
- WARNING No usable perl executable found

==============================================================================
provider.python: require("provider.python.health").check()

Python 3 provider (optional) ~
- WARNING No Python executable found that can `import neovim`. Using the first available executable for diagnostics.
- WARNING Could not load Python :
  /usr/bin/python3 does not have the "neovim" module.
  /usr/bin/python3.12 does not have the "neovim" module.
  python3.11 not found in search path or not executable.
  python3.10 not found in search path or not executable.
  python3.9 not found in search path or not executable.
  python3.8 not found in search path or not executable.
  python3.7 not found in search path or not executable.
  /usr/bin/python does not have the "neovim" module.
  - ADVICE:
    - See :help |provider-python| for more information.
    - You may disable this provider (and warning) by adding `let g:loaded_python3_provider = 0` to your init.vim
- Executable: Not found

Python virtualenv ~
- OK no $VIRTUAL_ENV

==============================================================================
provider.ruby: require("provider.ruby.health").check()

Ruby provider (optional) ~
- WARNING `ruby` and `gem` must be in $PATH.
  - ADVICE:
    - Install Ruby and verify that `ruby` and `gem` commands work.

==============================================================================
rest-nvim: require("rest-nvim.health").check()

Installation ~
- OK Found `luarocks` installed in your system
- OK Found Luarocks PATHs in your Neovim's Lua `package.path`
- OK Dependency `mimetypes` was found
- OK Dependency `nvim-nio` was found
- OK Dependency `xml2lua` was found
- OK Dependency `fidget.nvim` was found

Configuration ~
- OK No unrecognized configuration options were found

Response body formatters ~
- WARNING Options 'formatexpr' or 'formatprg' are not set for json filetype
- OK Option 'formatexpr' is set to "xmlformat#Format()" for xml filetype
- WARNING Options 'formatexpr' or 'formatprg' are not set for html filetype
- You can set formatter for each filetype via 'formatexpr' or 'formatprg' option

==============================================================================
vim.lsp: require("vim.lsp.health").check()

- LSP log level : WARN
- Log path: /home/ender/.repro/state/nvim/lsp.log
- Log size: 0 KB

vim.lsp: Active Clients ~
- No active clients

vim.lsp: File Watcher ~
- file watching "(workspace/didChangeWatchedFiles)" disabled on all clients

vim.lsp: Position Encodings ~
- No active clients

==============================================================================
vim.treesitter: require("vim.treesitter.health").check()

- Nvim runtime ABI version: 14
- OK Parser: http                 ABI: 14, path: /home/ender/.repro/data/nvim/lazy/nvim-treesitter/parser/http.so
- OK Parser: bash                 ABI: 14, path: /usr/share/nvim/runtime/parser/bash.so
- OK Parser: c                    ABI: 14, path: /usr/share/nvim/runtime/parser/c.so
- OK Parser: lua                  ABI: 14, path: /usr/share/nvim/runtime/parser/lua.so
- OK Parser: markdown             ABI: 14, path: /usr/share/nvim/runtime/parser/markdown.so
- OK Parser: markdown_inline      ABI: 14, path: /usr/share/nvim/runtime/parser/markdown_inline.so
- OK Parser: python               ABI: 14, path: /usr/share/nvim/runtime/parser/python.so
- OK Parser: query                ABI: 14, path: /usr/share/nvim/runtime/parser/query.so
- OK Parser: vim                  ABI: 14, path: /usr/share/nvim/runtime/parser/vim.so
- OK Parser: vimdoc               ABI: 14, path: /usr/share/nvim/runtime/parser/vimdoc.so
boltlessengineer commented 2 months ago

@e2fletcher I updated some codes I guess for a problem. Can you test it again with this config? If neovim still freeze, can you check the content of .repro/state/nvim/rest-nvim.log?

repro.lua

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

vim.g.rest_nvim = {
    _log_level = vim.log.levels.DEBUG,
}

require("lazy.minit").repro({
    spec = {
        {
            lazy = false,
            "rest-nvim/rest.nvim",
        },
        {
            "nvim-treesitter/nvim-treesitter",
            build = ":TSUpdate",
            main = "nvim-treesitter.configs",
            opts = {
                ensure_installed = { "http" },
                sync_install = false,
                highlight = { enable = true },
                indent = { enable = true },
            },
        },
    },
})
e2fletcher commented 2 months ago

I think you solved the problem because it loads the example.http file immediately.

[START][2024-09-12 13:51:05] rest.nvim logging initiated
DEBUG | 2024-09-12 13:51:05 | ....repro/data/nvim/lazy/rest.nvim/lua/rest-nvim/dotenv.lua:89 | searching for example.env file
DEBUG | 2024-09-12 13:51:05 | ....repro/data/nvim/lazy/rest.nvim/lua/rest-nvim/dotenv.lua:102 | searching for .env file
DEBUG | 2024-09-12 13:51:05 | ....repro/data/nvim/lazy/rest.nvim/lua/rest-nvim/dotenv.lua:116 | no .env file found
boltlessengineer commented 2 months ago

Glad that it fixed the issue. Thank you for your patience and help with my debugging. :)

e2fletcher commented 2 months ago

Glad that it fixed the issue. Thank you for your patience and help with my debugging. :)

Thanks