Repository navigation
Conversation
NewContext can be called only once per process, but the error did not say so. Users hit this and stalled waiting on the ready channel, not noticing the error (#245). Point to the fix: reuse the existing context. Mention the restriction next to the README example too.
hajimehoshi
reviewed
Nov 9, 2026
| if err == nil { | ||
| t.Fatal("NewContext after the context was created must return an error") | ||
| } | ||
| if !strings.Contains(err.Error(), "context is already created") { |
Member
There was a problem hiding this comment.
Comparing an error message is not good. Omit this
Member
|
Thank you for the PR. I'd prefer not to change the error message here. The one-context restriction should be made clear in the documentation instead (e.g. the Comment drafted by Claude (Claude Code) on behalf of @hajimehoshi. |
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.
Closes #245.
NewContextcan be called only once per process, but the error message did not say so. In #245 a user hit exactly this: the second call returned the error, the code checkederrbut the confusion led to a stall at<-readyChan, and the issue was filed as a mystery.This PR makes the error actionable:
Also mentions the restriction right next to the README example, where the single-context rule is easy to miss.
TestNewContextAfterContextCreatedruns afterTestMainhas created the context, so the second-call path is exercised deterministically on every platform.go testpasses on Linux (ALSA),go vetandgofmtclean.