Skip to content

dispose() not killing server due to mising terminateProcesses.sh when bundling this library #1741

@vaclavHala

Description

@vaclavHala

My misbehaving LSP server (does not terminate in response to shutdown) was not getting force killed in dispose() by the client.
After some debugging I found out it is because I did not know about the terminateProcess.sh used from processes.ts on linux and so it was not included in my .vsix extension (where all the .js code is bundled into a single extension.js so I don't include the whole node_modules tree) which always lead to terminate() silently failing.

I realize it is completely my fault I did not include the shell script in the bundle and after including it the client force kills the server as expected.

However, this is not a great experience for developer using the language client library. This ticket asks to (preferably) change how the shell script is provided so the .js code does not depend on external files - e.g. something like this

const pids = [process.pid.toString()]
const script = `
terminateTree() {
    for cpid in $(pgrep -P $1); do
        terminateTree $cpid
    done
    kill -9 $1 > /dev/null 2>&1
}

for pid in ${pids.join(" ")}; do
    terminateTree $pid
done
`
const result = cp.spawnSync("/bin/sh", [], { 
    input: script, 
    stdio: ["pipe", "inherit", "inherit"] 
})

or if that is undesirable, add some check into the processes.ts that will log warning for developer to see when the terminateProcess.sh can't be found in the expected location, with a hint that if I am bundling the library I need to ensure that file gets copied to appropriate location.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions