Open
Conversation
The PaginatedMessages interface used parallel arrays (items, itemHeaders, itemSerials, rawMessages) matched by index — fragile and wider than its sole internal consumer (View) needs. Since the type is no longer part of the public API, consolidate into HistoryItem (message + headers + serial per item) and HistoryPage. Also guard View.loadOlder() against concurrent calls — a second call while the first is still awaiting now silently no-ops instead of corrupting shared pagination state. AIT-670, AIT-671
7cdaaa5 to
ff9a4bc
Compare
owenpearson
reviewed
Apr 10, 2026
Member
owenpearson
left a comment
There was a problem hiding this comment.
Overall looks good, one question:
| @@ -197,8 +197,8 @@ export class DefaultView<TEvent, TMessage> implements View<TEvent, TMessage> { | |||
|
|
|||
| async loadOlder(limit = 100): Promise<void> { | |||
| if (this._closed || this._loadingOlder) return; | |||
Member
There was a problem hiding this comment.
Might be outside of the scope of this PR, but this looks weird to me: if you call loadOlder twice the second promise returned will resolve immediately even though the first promise is still busy loading older messages. Would it be better to reject the promise in this case?
Contributor
Author
There was a problem hiding this comment.
It's not really an error though so I don't think reject is a good idea, it's just to stop concurrent calls to loadOlder. When the first one resolves the data will be available.
IMO it's not really a problem, but if we think it is, then I'd say we return a promise that resolves when the inflight call to loadOlder resolves.
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.
The PaginatedMessages interface used parallel arrays (items, itemHeaders, itemSerials, rawMessages) matched by index — fragile and wider than its sole internal consumer (View) needs. Since the type is no longer part of the public API, consolidate into HistoryItem (message + headers + serial per item) and HistoryPage.
Also guard View.loadOlder() against concurrent calls — a second call while the first is still awaiting now silently no-ops instead of corrupting shared pagination state.
AIT-670, AIT-671