blacklight / nvim-http

An HTTP client for neovim inspired by vscode-restclient and the IntelliJ HTTP client
MIT License
87 stars 5 forks source link

Plugin hangs trying to cancel a request #6

Closed oxcafedead closed 3 months ago

oxcafedead commented 7 months ago

Steps to replicate:

Have a record with some non-existing hostname, e.g. GET http://101.102.103.104:8089/v1/models

The request takes long, it's expected as it probably tries to ping some non-existing IP. (However, any sane timeout here would be an option...) But, if I try to :HttpStop a screen just hangs.

After some really long time, it finally outputs an error in the status bar:

Error detected while processing function http#Stop[1]..provider#python3#Call[18]..http#Stop:
line    1:
HTTP request ERROR: ConnectionError: None: Max retries exceeded with url: /v1/models (Caused by None)

This freeze is inconvenient, so it's smth worth to fix.

oxcafedead commented 7 months ago

I think I figured out what is the reason: python is single threaded, so even when you invoke run in "vim async" wrapper - it anyway holds the main thread. Invoking an HttpStop later waits until the request succeeds (aka queue gets the result), processed joins and only after then stop handler is invoked.

I will send a draft PR with my fix proposal