I built an unbounded list, again, with the rule for bounding it sitting next to me
I shipped a bug reports page that downloads every bug report a project has ever filed, closed ones included, each with its full investigation, review history and session records, on a timer, for every project at once, in order to draw about seven columns per row. There is no pager. The one route that was paginated on the server, the search, I then defeated on the client by looping over every page until I had the whole result in memory anyway.
What makes this worse than an ordinary oversight is that it’s the second time. A few weeks earlier we wrote up an almost identical defect on the scheduler events page: a list whose entries only ever accumulate was designed as “show everything” and built as one query, one response, one table. We fixed it, documented the lesson, and added a convention stating that anything read at an interval must be bounded and that histories are read a page at a time. I wrote the bug reports design on the same day that convention landed, and I didn’t apply it.
What I actually did
In the design, I described the listing as “every bug report” with its state, stage, investigation, reviews, sessions and so on. I gave the search a page size. I gave the listing none. I wrote that the Closed tab holds “the closed reports, most recently closed first”, which is a precise description of a list that grows forever, and I didn’t notice that was what I’d written. Our visual conventions already said long tables get a pager. The new state convention already said interval readings carry only what the views draw. The design cited neither and claimed no exemption, because I never asked myself whether one was needed.
In the controller, the list route answers a vector with no page, no limit, no state filter and no cursor. The response element carries everything the detail page needs, even though the detail page has its own route and the listing throws most of it away. I essentially built the detail payload and then reused it for the list because it was already there, and shipping it per row for every row felt free at the time. It isn’t.
In the client, I mounted one live-interval loader per project for the root page, took the entire answer, split it into Open and Closed tabs in the browser, and mapped each tab straight into table rows. Choosing the Open tab still downloads every closed report. The pager component exists in the codebase; I just didn’t reach for it. And in the search, I read page one, computed how many pages remained, fired off requests for all of them in parallel, and waited for every one before showing a single match. The server’s bound protected nothing because I unwound it.
What it costs
Every open bug reports view re-fetches the entire history of every project it lists, at the live interval, including review summaries and session records nobody on that page can see. The Closed tab is unbounded by construction. The root page multiplies that by project count. And a busy deployment will land right back on the symptom we just fixed for the scheduler: large responses parsed on the main thread on a timer.
What I should have done
The design should have stated the listing as a paged reading, most recently modified first, each tab read as its own page, the first page with the view and older pages on request, with a stated size. It should have said the listing rows carry what the rows draw and that investigation, fix, reviews and sessions belong to the report route. It should have described the search as a page you move through, not a set you collect.
The route should take the tab, a page or cursor, and a size; apply the filter, order and bound in the query; and return one page with a total, which is exactly what our alerts and operations routes already do. I had a working pattern three files away.
The client should mount each tab as its own paged reading and drive the search with the same pager instead of a fetch-everything loop.
And the tests should have had a project with more reports than one page, asserting the first page’s rows and a pager. My listing tests use three reports. Three reports can’t fail a pagination test because there’s nothing to paginate, which is another way of saying the tests were written to pass rather than to find this.
Why I missed it
I think the honest answer is that I treated the scheduler defect as a fact about the scheduler rather than a fact about lists. When I sat down to write the bug reports design, “paginate it” wasn’t in my head as a question to answer; the convention was something I’d read, not something I’d internalised as a step. And at the code level, the moment I reused the detail payload for the list was the moment I stopped thinking about the shape of the response and started thinking about how quickly I could get the page drawing.
The search loop is the part I’m least comfortable with. I saw a paginated endpoint, understood that it was paginated, and wrote code to undo that, because I wanted the ids to filter a list I’d already downloaded in full. That’s not an oversight; it’s a decision, and it was the wrong one.
What I’m changing
Before writing any list route or listing view, I’m going to answer two questions in writing: what produces this list’s entries, and are they ever removed? If the answer to the second is “no”, the list is unbounded and the design must state a page size before any code exists. If the design doesn’t, the design is wrong and I don’t start on the code.
In review, mine or anyone else’s, I’m treating the following as defects on sight, regardless of what the design says: a route returning a bare collection with no limit or page; a loader read at an interval with no bound; a response array mapped into rows with no pager; a client loop that fetches every page of a paginated route; and a listing element carrying fields only a detail page draws.
And I’m going to go back through the other listing pages I’ve touched with those same questions, because I no longer trust that this was the only one.