File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,16 +43,17 @@ export default eventHandler(async (event) => {
4343 publishedAt : dbThought . publishedAt ,
4444 updatedAt : dbThought . updatedAt ,
4545 content : kvThought . content ,
46- ... kvThought . parsed ,
46+ body : kvThought . parsed . body ,
4747 } as Thought
4848 } ) ,
4949 )
5050
5151 const validThoughts = thoughts . filter ( ( thought ) : thought is Thought => thought !== null )
5252
53- // Calculate next cursor (timestamp of the last item)
54- const nextCursor = hasMore && validThoughts . length > 0
55- ? Math . floor ( validThoughts [ validThoughts . length - 1 ] . publishedAt . getTime ( ) / 1000 )
53+ // Calculate next cursor based on the last database item processed, not the last valid thought
54+ // This ensures pagination continues correctly even if some KV lookups fail
55+ const nextCursor = hasMore && dbThoughts . length > limit
56+ ? Math . floor ( dbThoughts [ limit ] . publishedAt . getTime ( ) / 1000 )
5657 : null
5758
5859 return {
You can’t perform that action at this time.
0 commit comments