I have an issue where I am trying to load a paginated query. It is inconsistent with loading, sometimes it works fine but a bunch of times it will be stuck on "LoadingFirstPage" status.
The query is pretty basic,
import { DataModel } from "convexDataModel";
import { GenericQueryCtx, paginationOptsValidator } from "convex/server";
import { Infer, v } from "convex/values";
import { Channel } from "@convex/channels/channels.schema";
export const readChannelsPaginatedValidator = v.object({
mode: v.optional(Channel.fields.mode),
paginationOpts: paginationOptsValidator,
});
export const readChannelsPaginated = async (
ctx: GenericQueryCtx<DataModel>,
args: Infer<typeof readChannelsPaginatedValidator>,
) =>
ctx.db
.query("channels")
.withIndex("by_setupStage_visibility_mode", (q) =>
q
.eq("setupStage", "complete")
.eq("visibility", "public")
.eq("mode", args.mode ?? "schedule"),
)
.order("desc")
.paginate(args.paginationOpts);
I looked at the convex logs and I even noticed that it doesn't show the query hitting the backend, like it never even queried.
Here is the usePaginatedQuery logic:
import { usePaginatedQuery } from "convex/react";
import { api } from "convexApi";
export const CHANNEL_PAGINATION_SIZE = 15;
export const useGetChannelsPaginatedQuery = (args: {
mode?: "schedule" | "watchparty";
}) =>
usePaginatedQuery(
api.channels.queries.getChannelsPaginated,
{
mode: args.mode,
},
{
initialNumItems: CHANNEL_PAGINATION_SIZE,
},
);