Compile commands file watchers are leaked without being closed #12946
Description
Environment
- OS and Version: Windows 10
- VS Code Version: 1.95.1
- C/C++ Extension Version: V1.22.11
- If using SSH remote, specify OS of remote machine:
Bug Summary and Steps to Reproduce
Bug Summary:
When using compileCommands
in a configuration, deleting the json file causes the fallback function checkCompileCommands()
in src\LanguageServer\configurations.ts
to dispose the file watchers without closing them.
Steps to reproduce:
- Use the
compileCommands
configuration with a path to acompile_commands.json
. - Update the file's timestamp. (
touch
it or compile a CMake project which updates it)CppProperties.compileCommandsFile
is updated with a value.
- Delete or rename the file.
- next periodic call to
checkCompileCommands()
will enter the error case and leak the file watchers.
// in checkCompileCommands()
fs.stat(compileCommandsFile, (err, stats) => {
if (err) {
if (err.code === "ENOENT" && this.compileCommandsFile) {
// file watchers should be closed here
this.compileCommandsFileWatchers = []; // reset file watchers
Expected behavior:
checkCompileCommands()
should close the file watchers before disposing.
Configuration and Logs
{
"configurations": [
{
"name": "compdb1",
"compileCommands": "${workspaceFolder}/compile_commands_1.json",
"intelliSenseMode": "windows-msvc-x64",
"cStandard": "c17",
"cppStandard": "c++17"
},
{
"name": "compdb2",
"compileCommands": "${workspaceFolder}/compile_commands_2.json",
"intelliSenseMode": "linux-gcc-x64",
"cStandard": "c17",
"cppStandard": "c++17"
}
],
"version": 4
}
Other Extensions
No response
Additional context
No response
Metadata
Assignees
Type
Projects
Status
Done