All entries

    GitHub CLI Event Streams: Wait for a PR Review Without Polling in a Loop

    Use GitHub CLI Event Streams to wait for pull-request changes when eligible. Check CLI version, preview access, timeout and current PR state before acting.

    A pixel-art developer mailbox receives a pull-request event while an abandoned polling clock sits beside it in a New York workshop.
    Original GPT-generated pixel-art editorial illustration; conceptual artwork, not a product screenshot or test result.

    GitHub CLI 2.105.0 adds commands for waiting on pull-request events instead of repeatedly polling in a loop. The feature also requires access to GitHub Event Streams, which is in preview. Upgrading the CLI is therefore necessary for the described commands but is not by itself proof that your account can use the service.

    Understand what polling was doing

    A polling loop repeatedly asks whether state changed, even when nothing happened. That can waste requests and complicate retry logic. An event stream waits for a relevant signal instead. It changes how a workflow wakes up, not the underlying rules for whether the workflow may act.

    This is especially useful for an agent waiting for a review or check completion. But a listener must still have a lifetime, error handling and a way to reconcile current state. Replacing a loop with a stream does not eliminate operational design.

    Check the two availability gates

    First inspect the installed GitHub CLI version. Then check access to the Event Streams preview. The November 18 announcement names both requirements. A command missing from an old binary and a command denied by preview eligibility are different problems.

    Use the current command help for event selection and output fields. Do not invent event names from a webhook example if the CLI uses a different supported vocabulary. The simple invocation below illustrates the announced entry point with a placeholder URL.

    Shell — replace with an authorised PR URL and check current help
    gh --version
    gh event listen --help
    gh event listen https://github.com/OWNER/REPOSITORY/pull/123
    EXPLAINED / SIDE BY SIDE

    An event wakes the workflow; current state makes the decision

    A conceptual automation pattern, not a guarantee of event delivery or permission to merge.

    Waiting

    1. Subscription

      Listen for documented events with a bounded lifetime.

    2. Event arrives

      Treat it as a signal that relevant state may have changed.

    Acting

    1. Refetch PR state

      Check the current head, reviews and required checks.

    2. Normal action

      Proceed only under existing permissions and branch rules.

    THE KEY DISTINCTION

    An old review event is not approval for a newer commit.

    Author-created explanatory diagram. Arrows show the process described in the article, not measured performance.

    Bound the listener and parse structured output

    GitHub describes options for a count, following the stream, a timeout and structured output selection. Choose a bounded duration for a one-time task. A process that waits forever is not automatically a reliable automation; it can retain resources and make completion unclear.

    Parse the documented JSON rather than scraping terminal prose. Keep authentication in the CLI's supported credential flow. Do not place a token directly in a public command, workflow file or article to make the example easier to copy.

    Scroll the table horizontally to see all columns.

    Bound the listener and parse structured output
    ConcernDesign choiceFailure to prevent
    No event arrivesExplicit timeout and current-state checkInfinite waiting
    Listener reconnectsReconcile state and tolerate duplicatesDuplicate actions
    New commit arrivesCompare current head before actingActing on stale review evidence
    Check completesInspect the required check resultTreating completion as success
    Preview unavailableUse a supported bounded fallbackRepeated failing command loops

    Treat events as notifications, not final authority

    When a review event arrives, fetch the current PR state. The head may have changed since the review was submitted. A completed check can have failed. A merge conflict can appear after another branch lands. The decision must use current state and the repository's existing rules.

    For an action with side effects, make duplicate handling explicit. Store or compare a meaningful operation identity where appropriate. An event delivered twice should not post two comments, trigger two deployments or apply the same change twice.

    Preserve branch protections

    Do not use administrator bypass to make an event-driven workflow succeed. Required checks and approvals remain required. If an automation may merge a narrow verified change, constrain its scope and expected head and refuse unrelated work or unresolved checks.

    Keep permissions minimal. A listener that only reports status does not need broad repository-write access. Separate observation from mutation so a failure in event parsing cannot accidentally become a permission to modify code.

    Verify the lifecycle, not only the happy event

    Test timeout, cancellation, duplicate notification and stale-head behaviour with a disposable repository or mock event layer. Confirm that subscriptions and processes are cleaned up through the documented controls. Keep logs free of credentials and private event payloads.

    The benefit is a quieter, more direct waiting mechanism. The safe design still checks current truth before acting. That distinction applies to many systems: an event tells you to look; the authoritative state tells you what is now allowed.

    Frequently asked questions

    Which CLI version does the announcement require? GitHub names gh 2.105.0 or later for the new event commands. Check the installed version and current manual because preview commands can change.

    Does upgrading gh automatically grant Event Streams access? No. The announcement says the commands require Event Streams preview access and points to a waitlist. Verify account eligibility separately from the binary version.

    Can an event listener merge a PR just because a review arrives? It should not infer merge readiness from an event alone. Refetch the current PR head, reviews and required checks, then follow normal permissions and branch protections.

    FURTHER READING

    Sources

    Technical references checked .

    END OF ENTRY / 149
    Eeshan Singh with Big Ben in London
    BEHIND THE JOURNAL

    Eeshan Singh

    I’m Eeshan Singh Pokharia, an AI Full Stack Developer and CoFounder of UltraFit360. I work across AI features, full-stack product development, and web and mobile experiences—from Figma and frontend interactions to the systems behind them.

    This article explains the announced workflow and a safe automation design. It does not claim I enabled a preview subscription, ran a paid service or created a background listener for your repository.

    Meet the author
    THE CONVERSATION

    Your side of the story.