-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intermittent Request textDocument/completion failed
from R LSP
#3467
Comments
I may feel like it happens more when I am typing really fast, maybe? |
not sure why yet but this is where it comes from |
If you can reproduce, can you also capture and report the |
Okay, I have a decent idea about what is happening and can reproduce locally (though, nothing reliable). In posit-dev/ark#361 @lionel- introduced some more advanced logging of LSP errors, including sending LSP errors to the frontend, which we were not doing much before: I have a feeling this error was happening before and was logging it to I managed to trigger locally in a debug build (which includes file locations)
And I have long thought that our signature-help method needs a rewrite, it has been the cause of quite a few issues over the past few months. I am not sure what the exact issue is yet though. Here is the reverse engineered script, I managed to get it to fire sometimes while finishing out library(tidyverse)
library(arrow)
library(pins)
housing <- tibble::as_tibble(mlr3data::kc_housing) |>
mutate(date = as.Date(date)) |>
select(price, bedrooms, bathr)
summary(housing$date)
path1 <- here::here("data", "housing.parquet")
path2 <- here::here("data", "housing_monitoring.parquet")
housing |>
filter(date < ymd("2015-01-01")) |>
arrange(date) |>
write_parquet(path1)
housing |>
filter(date >= ymd("2015-01-01")) |>
arrange(date) |>
write_parquet(path2)
library(tidymodels)
set.seed(123)
housing_split <- housing |>
filter(date < ymd("2015-01-01")) |>
arrange(date) |>
initial_split(prop = 0.8)
housing_train <- training(housing_split)
housing_test <- testing(housing_split)
housing_rec <-
recipe(price ~ bedrooms + bathrooms + sqft_living + yr_built,
data = housing_train)
housing_fit <-
workflow(
housing_rec,
rand_forest(trees = 200, mode = "regression")
) |>
fit(data = housing_train)
augment(housing_fit, new_data = slice_sample(housing_test, n = 10)) |>
select(-aka_name)
library(vetiver)
v <- vetiver_model(inspect_fit, "julia.silge/chicago-inspections-rstats")
board <- board_connect()
board |> vetiver_pin_write(v)
vetiver_deploy_rsconnect(
board = board,
name = "julia.silge/chicago-inspections-rstats",
predict_args = list(debug = TRUE),
account = "julia.silge",
appName = "chicago-inspections-rstats-model-api",
forceUpdate = TRUE
)
hoursing_fit <-
workflow(
housing_rec,
rand_forest(trees = 200, mode = "regression")
) |>
fit(data = housing_train)
augment(housing_fit, new_data = slice_sample(housing_test, n = 10)) |>
select(-aka_name)
|
Thank you for looking into all that detail! I believe you are exactly right about where the error is happening in this case, and I believe I have also seen it when selecting columns within a dplyr verb, in a Quarto chunk. |
I can consistently reproduce, it seems to happen when typing at the n + 1 position in an argument list of a function with n parameters. I get a Another issue occurs in functions taking Screen.Recording.2024-06-24.at.19.20.57.movfoo <- function() {}
foo2 <- function(x) {}
foo()
foo2()
bar <- function(...) {}
bar() |
Here's a stack trace and
This is a very tricky problem due to a coincidence that the function name |
For posit-dev/ark#429 from at:yutannihilation Workaround to silence error notifications of #3467 And for posit-dev/ark#424
I was investigating #3467, particularly the `completionItem/resolve` failure pop up you get when you do ```r bar <- function(...) {} bar() ``` And hit `Tab` while your cursor is here `bar(<tab>)` <img width="1483" alt="Screenshot 2024-08-29 at 4 37 52 PM" src="https://github.com/user-attachments/assets/b45e0121-ebae-49f7-be1a-9c9228f7fb69"> posit-dev/ark#431 is an attempt to fix the underlying issue here, and I do think we will merge a variant of that. However, I realized that this is yet again a case of VS Code being too aggressive about showing non-actionable LSP messages to the user, so I went to see if we could turn this one off. As usual, there was an option for this! Note that the `RevealOutputChannelOn` enum is used in [exactly 1 place](https://github.com/search?q=repo%3Amicrosoft%2Fvscode-languageserver-node%20RevealOutputChannelOn&type=code) in the `Client` middleware: Particularly, right [here](https://github.com/microsoft/vscode-languageserver-node/blob/14ddabfc22187b698e83ecde072247aa40727308/client/src/common/client.ts#L1180-L1188) in `logOutputMessage()`, where it helps decide whether or not to `showNotificationMessage()` to the user when `showNotification` is `true` It defaults to `RevealOutputChannelOn.Error`, but if we set this to `RevealOutputChannelOn.Never` then it means that every instance of `this.error()` in that `client.ts` file will no longer show the user an error notification. Note that `Request completionItem/resolve failed` was [one of these cases](https://github.com/microsoft/vscode-languageserver-node/blob/14ddabfc22187b698e83ecde072247aa40727308/client/src/common/client.ts#L2239). The most important thing to note is that even with `Never`, the error message is always always [always logged](https://github.com/microsoft/vscode-languageserver-node/blob/14ddabfc22187b698e83ecde072247aa40727308/client/src/common/client.ts#L1181) to the corresponding `Positron Language Server: R x.y.z (console)` Output channel. This is great. This is exactly what we want...and nothing more. If the error doesn't crash the LSP, we probably don't want to show it to the user, even if there is some kind of bug that we probably should fix, because the user can't do anything about that! See also this issue which describes in nice detail how this `revealOutputChannelOn` option works, confirming my analysis here: microsoft/vscode-languageserver-node#818 As further evidence, we are not alone in wanting to do this 🫡 https://github.com/search?q=RevealOutputChannelOn.Never&type=code Notably: - The PowerShell LSP does this - [vscode-R](https://github.com/REditorSupport/vscode-R/blob/b196c7d8257a04509de68a3bfe7acf9c1f2fba85/src/languageService.ts#L138) does too - [rust-analyzer](https://github.com/rust-lang/rust-analyzer/blob/master/editors/code/src/lang_client.ts) effectively does too by overriding `handleFailedRequest()` entirely, but I don't think we need to go that far.
I haven't seen this in a while, thanks for the fixes! |
As I am working on various projects, I am noticing that occasionally I see this error:
I have no idea what I am doing that prompts this. Just now, I was typing in a
.R
file but I have also observed in while working in Quarto.Here are the LSP logs, which were what that "Go to output" prompts me to go to:
lsp.log
The text was updated successfully, but these errors were encountered: