Skip to content

ax watch hangs forever on a task that doesn't exist #435

Not planned

Description

@vincent0426

ax watch task does-not-exist prints Watching task default/does-not-exist... and never returns.

WatchTask ignores the NotFound from GetTask and waits for updates that never come. It should return codes.NotFound, like GetTask does.

Opening PRs seems to be limited to collaborators right now, so here's the fix with a test: vincent0426@d36bb3d

Activity

  1. Yi-111-a commented on Oct 1, 2026

    @Yi-111-a

    Confirming the diagnosis with a reproduction, and the fix matches what the issue describes.

    Verified on ac23328 (current main):

    internal/server/server.go:386 discards the GetTask error:

    if initial, err := s.store.GetTask(ctx, atespace, req.Name); err == nil {

    Then cmd/ax/main.go:683 calls stream.Recv() under context.Background(), so nothing ever ends the wait.

    A regression test that reproduces the hang against unmodified main (5s deadline, so it can only pass if the server actively returns the error):

    --- FAIL: TestServer_WatchTask_MissingTaskReturnsNotFound (5.00s)
        WatchTask on a missing task: got rpc error: code = DeadlineExceeded
        desc = context deadline exceeded, want NotFound
    

    Proposed change — resolve the task before subscribing, and map store.ErrNotFound to codes.NotFound, matching GetTask:

    initial, err := s.store.GetTask(ctx, atespace, req.Name)
    if err != nil {
        if errors.Is(err, store.ErrNotFound) {
            return status.Errorf(codes.NotFound, "task %q not found in atespace %q", req.Name, atespace)
        }
        return status.Errorf(codes.Internal, "getting task: %v", err)
    }
    
    ch, closer, err := s.store.WatchTask(ctx, atespace, req.Name)

    The INITIAL frame reuses the already-resolved task, so the store is read once per watch instead of twice. With this, ax watch task does-not-exist exits the same way ax get task does-not-exist does; watches on existing tasks are unaffected.

    go build ./internal/..., go vet ./internal/... and the full go test ./... pass, including TestServerGRPC, which covers the existing INITIAL/MODIFIED path.

    I tried to open the PR, but non-collaborator PR creation now returns "does not have the correct permissions to execute CreatePullRequest" (my earlier #408 was accepted on 2026-09-25, so this looks recent). Happy to open it as soon as that's possible — or a maintainer can pick up the patch above, which is also on the fork branch fix/watch-task-not-found.

  2. self-assigned this
    on Oct 13, 2026
  3. erain commented on Oct 13, 2026

    @erain
    Collaborator

    I am taking this on, building on the diagnosis and reproductions from @vincent0426 and @Yi-111-a. I will keep watch registration before the initial read so updates cannot fall into a lookup/subscription gap, return NotFound for missing tasks and Internal for backend errors, and test subscription cleanup, cancellation, initial/modified delivery, and the registration race. The PR will include baseline failure and captured CLI/API/Redis evidence.

  4. rakyll commented on Nov 25, 2026

    @rakyll
    Member

    Obsolete: ax watch and WatchTask were removed (#522).

    We are closing this as part of a cleanup after the significant changes in v0.4.0, because it is probably obsolete or out of scope now. If you think this is a mistake, please reopen it (or leave a comment if you can't reopen it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions