Skip to content

Guard completion requests against misbehaving callbacks. - #108

Merged
floitsch merged 2 commits into
mainfrom
floitsch/completion-timeout
Jul 23, 2026
Merged

Guard completion requests against misbehaving callbacks.#108
floitsch merged 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.

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.
@floitsch
floitsch merged commit e13a554 into mainJul 23, 2026
7 checks passed
@floitsch
floitsch deleted the floitsch/completion-timeout branch July 23, 2026 15:09
Sign up for freeto 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

@floitsch