Repository navigation
0.2.0: shutdown(), maxTokens and status on HTTP errors - #5
Merged
Merged
Conversation
…tatus
A host that exited left `opencode serve` running and holding its port, and
nothing in the package could stop it: children are spawned detached, so a
terminal's Ctrl-C never reaches them, and the shared server is module-private.
Every spawn now goes through one registry, and `shutdown({ graceMs })` sends
SIGTERM to every group the package still owns, SIGKILL to each of them after
the grace, and resolves once they are gone. It shares one in-flight promise,
never rejects, and the package still installs no signal handler: a host that
traps SIGINT calls it. An opencode call in flight when its server dies by a
signal now fails at once instead of waiting out the 30 s boot timeout, and a
claude-code failure caused by a signal names the signal.
`StreamOptions.maxTokens` (also on complete()) is sent by the two HTTP
adapters when it is a positive safe integer; anthropic keeps its 32000
default and openai-compatible still sends nothing unless asked. Error chunks
from a non-ok HTTP response carry the provider's `status`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A host that exited left
opencode serverunning and holding its port, and the package offered no way to stop it. Children are spawned detached, so Ctrl-C never reaches them.max_tokenscould not be set per call, and an error chunk carried its HTTP status only inside the message text.What
shutdown({ graceMs = 3000 }):opencode serve;StreamOptions.maxTokens, also oncomplete():anthropicandopenai-compatiblewhen it is a positive safe integer;anthropickeeps its 32000 default, andopenai-compatiblestill sends nothing unless asked;LLMStreamChunk.status: the provider's HTTP status on an error chunk from a non-ok response. The error text is unchanged.Additive only: no existing consumer changes behaviour. The version is 0.2.0 because the release adds public API.
Verified locally
verify:packok (26 files).graceMs,maxTokensvalidation andstatus. Each one was checked to fail against the code it guards.Known limits
kill -9of the host still leaves the server running.