Skip to content

Guard completion requests against misbehaving callbacks.#108

Open
floitsch wants to merge 2 commits into
mainfrom
floitsch/completion-timeout
Open

Guard completion requests against misbehaving callbacks.#108
floitsch wants to merge 2 commits into
mainfrom
floitsch/completion-timeout

Conversation

@floitsch

Copy link
Copy Markdown
Member

Completion requests run while the user is waiting for the shell to
react to a tab-press, and shells don't interrupt slow completion
commands: a completion callback that hangs (for example on a network
operation) blocks the user's prompt until they hit ctrl-c.

Bound the time a completion request may take to 5 seconds and exit
with a non-zero code on timeout or exception, which the generated
completion scripts already treat as 'no completions'. This also keeps
a throwing callback from dumping a stack trace onto the user's prompt.

Additionally, silence the default logger while handling a completion
request: candidates are printed to stdout, so any library logging from
a completion callback (for example the file-lock logging of the cache)
would corrupt the completion output.

floitsch added 2 commits July 16, 2026 16:06
Shells don't interrupt slow completion commands: a completion callback
that hangs (for example on a network operation) blocks the user's
prompt until they hit ctrl-c. Give up after 5 seconds and exit with a
non-zero code, which the generated completion scripts already treat as
'no completions'. The same guard also silences callbacks that throw,
which would otherwise dump a stack trace onto the user's prompt.
Completion candidates are printed to stdout, so any library logging
from completion callbacks (for example the file-lock logging of the
cache) would corrupt the completion output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant