huggingface / llm-ls

LSP server leveraging LLMs for code completion (and more?)
Apache License 2.0
602 stars 49 forks source link

In Windows, it will cause bug sometimes. #45

Closed mikeshi80 closed 3 months ago

mikeshi80 commented 11 months ago

https://github.com/huggingface/llm-ls/blob/f58085b8127dc09ae09645e04019a668a85e4976/crates/llm-ls/src/main.rs#L795

Instant::now() maybe return a value smaller than MAX_WARNING_REPEAT (3600s) in my Win11, and it will cause the checked_sub return None, that make program show error message "instant to be in bounds" and exit exceptionally.

I think it could be the reason: https://doc.rust-lang.org/std/time/struct.Instant.html#underlying-system-calls

Windows use QueryPerformanceCounter as underlying system call.

My OS is Win11 Home Edition, 23H2 version.

mikeshi80 commented 11 months ago

Maybe std::time::SystemTime::now is the right option, not std::time::Instant::now

zhangwenhao666 commented 4 months ago

I also encountered the same problem on the Windows system. Later I checked GPT and he replied that it was possible that the MAX_WARNING_REPEAT setting was too large, so I changed const MAX_WARNING_REPEAT: Duration = Duration::from_secs(3_600); to const MAX_WARNING_REPEAT: Duration = Duration::from_secs(3_60);This problem is solved. I don’t know if there are any other problems with this solution.