feat(event-streams): improve subscribe UX#1534
Open
developerkunal wants to merge 5 commits into
Open
Conversation
…12.0 Adds --no-reconnect / --max-reconnects flags wired to the new option.WithoutStreamReconnection / WithMaxStreamReconnectAttempts in go-auth0 v2.12.0, and --list-event-types to discover valid --event-type values. Filters connection_timeout error frames up front so JSON, output file, and rendered output all skip the SDK's reconnect artifacts. Tracks server-emitted error events separately from per-type counts and surfaces them in the disconnect summary alongside session duration. Aligns rendered event rows with fixed-width columns, prints a more readable resume hint that wraps cleanly on long cursors, and returns a single error reporting all invalid --event-type values at once instead of bailing on the first.
ramya18101
reviewed
May 29, 2026
Comment on lines
+290
to
+292
| cli.renderer.Infof("Resume from cursor %s:", ansi.Faint(shortOffset(lastOffset))) | ||
| cli.renderer.Output(" " + ansi.Cyan("auth0 event-streams subscribe --from \\")) | ||
| cli.renderer.Output(" " + ansi.Cyan(lastOffset)) |
Contributor
There was a problem hiding this comment.
We are adding lastOffSet twice in the output.. one in the info and another in the output command.. Can this be reverted..?
duedares-rvj
previously approved these changes
May 29, 2026
… rotations The server rotates long-lived SSE connections every few minutes, which previously exhausted the SDK's lifetime reconnect cap and silently ended the session. Replace SDK-internal reconnection with a CLI-level resume loop that re-subscribes from the last cursor, so the session stays continuous and no events are missed. Backoff uses exponential delay with full jitter and only accrues on consecutive zero-progress failures; any forward progress resets it so healthy rotations reconnect instantly and silently. The server-advertised SSE retry directive is honored as a floor. --max-reconnects now caps consecutive failed attempts (0 = unlimited while progress is made), and Ctrl+C cancels via context so the summary always prints. Also collapse the duplicated resume hint into a single line.
A connection that flaps (delivers a frame then dies immediately) counts as forward progress and resets the backoff, which could spin in a tight reconnect loop. Enforce a 1s floor between attempts based on how long the session actually lasted, so healthy long-lived sessions are unaffected but flapping connections are paced.
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.
🔧 Changes
Improves the
auth0 event-streams subscribeUX so live event inspection is easier to read, easier to interrupt, and easier to resume, and keeps long-lived sessions alive across the server's periodic connection rotations.Discoverability
--list-event-typesprints every value accepted by--event-typeand exits without opening a subscription.--event-typevalues are now collected up front and reported in a single error listing every bad value, instead of bailing on the first. The error points at--list-event-typesfor the full list, and the SDK's internal Go type name no longer leaks into user output.Reconnect behavior
retry:directive is honored as a floor, and a 1s minimum interval between attempts prevents a flapping connection from spinning in a tight loop.--no-reconnectexits cleanly when the connection ends instead of resuming.--max-reconnects Ncaps consecutive failed reconnect attempts before giving up (0 = retry indefinitely while progress is being made). Mutually exclusive with--no-reconnect.Output cleanups
connection_timeoutframes (a protocol artifact emitted right before the server drops the SSE connection) are filtered up front, so the rendered output,--json/--json-compact, and the--output-filecapture all stay consistent and free of reconnect noise.errorevents (rate limits, auth, etc.) render on their own row, are tracked in a separateErrors:counter in the summary, and no longer pollute per-type event counts.Errors:line when non-zero, and groups per-type counts under aBy type:heading, sorted by count desc with aligned columns.Bumps
github.com/auth0/go-auth0/v2: v2.11.0 → v2.12.0.📚 References
None.
🔬 Testing
Unit tests added in
internal/cli/event_streams_subscribe_test.gocovering the pure helpers:summarizeEventfor heartbeat, error,connection_timeout, and concrete-event envelope variants.padRightfor short, equal, long, and empty inputs.shortOffsetfor short, boundary, and long cursor truncation.colorForEventTypeconfirms the original type string survives the color wrap for every suffix branch pluserrorand unknown.invalidEventTypesErrorcovers single-value and multi-value cases, plus a guard that the SDK's internal type name never leaks into user output.reconnectBackoffconfirms an immediate reconnect on a healthy rotation, that jittered delays stay within their exponential ceiling and never exceed the 30s cap, and that the serverretry:directive acts as a floor.Run with:
Manual end-to-end testing against a live tenant:
auth0 event-streams subscribeleft running across multiple server connection rotations to confirm the session stays continuous with no event loss and no reconnect noise, then Ctrl+C to confirm the summary shows duration, event counts, errors when any, heartbeats, theBy type:block, and a readable resume hint.auth0 event-streams subscribe --list-event-typesto confirm the full list prints and the command exits.auth0 event-streams subscribe --event-type bad.value --event-type also.badto confirm both bad values are reported in one error.auth0 event-streams subscribe --no-reconnectand--max-reconnects 1to confirm both flags are accepted and mutually exclusive.📝 Checklist