Repository navigation
Conversation
HTTPEmbedder sent every request with http.DefaultClient, which has no timeout, and the Embedder interface took no context, so a hung embeddings endpoint blocked Analyze forever. Add a Timeout field (zero = 30s default) enforced through the request context, and an opt-in ContextEmbedder interface plus AnalyzeContext so callers can cancel an in-flight request without breaking existing Embedder implementations. Analyze remains a wrapper around context.Background().
Member
|
Hi @bfs2021, thank you for taking the time to send this. We're closing it, and it's not about the quality of the change. The issue it fixes is labelled If you'd like to keep contributing, we'd welcome help on our Thanks again! |
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.
Problem
HTTPEmbeddersent every embeddings request throughhttp.DefaultClient, which has no timeout, and theEmbedderinterface carried nocontext.Context. If the embeddings endpoint accepted the connection but never answered,Analyzeblocked forever and the caller's deadline or cancellation could not stop it. Fixes #14.Root cause
semdiff/semdiff.gobuilt the request withhttp.NewRequestand sent it withhttp.DefaultClient.Do, so neither a request deadline nor the caller's cancellation reached the outbound HTTP call, andEmbed(texts []string)had no context parameter to propagate one.Fix
HTTPEmbedder.Timeout time.Duration(zero means the package default of 30s).Embednow derives a deadline from it viacontext.WithTimeout, so both the round trip and the response body read are bounded.ContextEmbedderinterface (EmbedContext(ctx, texts)) plusAnalyzeContext(ctx, ...), andHTTPEmbedderimplements it withhttp.NewRequestWithContext.Analyzestays as a wrapper aroundcontext.Background(), so existingEmbedderimplementations (LexicalEmbedder, the server,promptctl) compile unchanged.http.Clientinstead ofhttp.DefaultClient; the client sets no timeout of its own because the per-request deadline lives in the context.analyzeChange/expand/deltaText/embedOnepath.Testing
TestEmbedderTimeout(the repro from the issue, with a 100ms configured timeout): it fails on the old code withEmbed still blocked after 5s: no timeoutand passes after the fix.TestEmbedderDefaultTimeout(zero value resolves to a finite timeout) andTestAnalyzeContextCancellation(cancelling the context aborts the in-flight request withcontext.Canceled).deltaTexthelper.go test ./...green on Windows/amd64, Go 1.27.3;go vet ./...clean;gofmt -l semdiff/empty. CI runsgo test ./...andbuf lint; proto files untouched.