AnWeber / vscode-httpyac

Quickly and easily send REST, Soap, GraphQL, GRPC, MQTT and WebSocket requests directly within Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=anweber.vscode-httpyac
MIT License
237 stars 20 forks source link

Imports are not being reloaded before request execution #110

Closed smaktacular closed 2 years ago

smaktacular commented 2 years ago

I'm using the import directive to separate my Personal Access Token (PAT) from my requests. That means I have a file .pat.http with the following contents :

@Token = abcd ....

I then use the token in my requests, which is working fine, using:

# @import .pat.http

and

GET http://localhost/request
Authorization: Bearer {{Token}}

Whenever I regenerate the file containing the @Token via Powershell script, the new contents of the file are not used until I reload VsCode (e.g. CTRL+SHIFT+P -> Developer: Reload WIndow)

I'm not 100% sure if this intended behavior or not. , but imho it'd be less error prone if the contents of the imported files would be reloaded on/before every request.

AnWeber commented 2 years ago

I'm going to take a look at it. But it was more a conscious decision to not waste resources unnecessarily. I rely on vscode's update mechanism for changes to *.http files (notifies only on open files) and don't launch my own filesystem watcher. I will eventually reconsider though. As a small workaround I could recommend to simply write the PAT to an .env file, which are located in the root of the project. .env data is always reloaded.

AnWeber commented 2 years ago

It also works without FS Watcher. As long as the file is not opened, the file is reloaded. As soon as it is open within VSCode, the content is updated by VSCode events (https://github.com/AnWeber/httpyac/commit/4f7bcabdc78f43f3efcd049dce8874604fbbf0be)

AnWeber commented 2 years ago

I have now published the fix with v5.2.0.

AnWeber commented 2 years ago

I'm afraid I'll have to take fix back with the next version. The change causes quite a few problems and unfortunately must be solved more complicated. For this reason, when updating pat.http please just use the command httpyac.reset manually or my recommended workaround with `.env