Fix timestamp message search hanging on empty partitions and 'topic undefined' 404 on navigation - #2623
Closed
jvorcak wants to merge 2 commits into
Closed
Fix timestamp message search hanging on empty partitions and 'topic undefined' 404 on navigation#2623jvorcak wants to merge 2 commits into
jvorcak wants to merge 2 commits into
Conversation
A start offset resolved by timestamp is -1 on an empty partition, which was clamped to highWaterMark-1 (= -1 again), and kgo interprets At(-1) as 'start at the end' — an indefinite live tail. The round-robin also allocated a message to such partitions, so the request could never be satisfied and only ended via cancellation: '[unknown] request was cancelled while waiting for messages'. Exclude partitions with nothing to consume (high <= low) from the consume request, except for deliberate live tail, and complete immediately (instead of erroring) when all partitions are empty. Reference: Zendesk ticket 7199.
nuqs flushes queued URL updates inside startTransition(() => navigate({ to,
from })). Frequent synchronous re-renders (e.g. message-search progress) keep
preempting that transition; when the user navigates away, their navigation
commits first and the deferred flush runs navigate with a 'from' route that
is no longer matched. TanStack Router then interpolates the missing path
params as the literal string 'undefined', navigating to /topics/undefined
and showing a persistent 404 ("The topic 'undefined' does not exist").
Wrap the tanstack-router adapter so a flush is dropped when its originating
route is no longer in the router's pending/current matches.
Reference: Zendesk ticket 7199.
Contributor
✅ Clean — no registry drift, off-token colours, or ad-hoc classesApp:
Generated by lookout audit-changes. |
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.
Fixes two customer-reported issues (Zendesk ticket 7199).
1. Backend: `[unknown] request was cancelled while waiting for messages` with Timestamp start offset
A start offset resolved by timestamp is `-1` on an empty partition. `calculateConsumeRequests` clamped it to `highWaterMark - 1`, which is `-1` again for an empty partition — and kgo interprets `At(-1)` as "start at the end", i.e. an indefinite live tail. The round-robin allocator also assigned a message to such partitions, so the request could never be satisfied and only ended via cancellation after the server deadline (~35s). One empty partition in an otherwise populated topic was enough to make every timestamp search fail this way.
Fix: exclude partitions with nothing to consume (`high <= low`) from the consume request (except deliberate live tail), and complete immediately — instead of returning an error — when all partitions are empty.
Verified live via `buf curl` against the streaming RPC:
New unit tests: `TestCalculateConsumeRequests_EmptyPartitions`, `TestCalculateConsumeRequests_AllPartitionsEmpty` (live tail still includes empty partitions).
2. Frontend: 404 "The topic 'undefined' does not exist" when navigating away mid-fetch
nuqs flushes queued URL updates inside `startTransition(() => navigate({ to, from }))`. Frequent synchronous re-renders during an in-flight message search ("Fetching data...") keep preempting that transition; when the user clicks away, their navigation commits first and the deferred flush then runs `navigate` with a `from` route that is no longer matched. TanStack Router interpolates the missing `$topicName` param as the literal string `undefined`, navigating to `/topics/undefined` — a persistent 404 (console warning: `Could not find match for from: /topics/$topicName/`).
Fix: wrap the tanstack-router nuqs adapter (`utils/nuqs-tanstack-adapter.tsx`) so a flush is dropped when its originating route is no longer in the router's pending/current matches, checked at flush time.
Verified with a headless-browser repro (empty topic, start a hanging search, click "Topics" while "Fetching data..." shows): before → `/topics/undefined` + persistent 404, 3/3 runs; after → lands on `/topics/` normally.
Repro (for QA)
Testing