TripleSpeederT
Convex Community3y ago
6 replies
TripleSpeeder

Strange error when trying to use search

I'm getting a strange error as soon as I'm trying to search on a table with searchIndex. Browser console keeps printing this, repeating forever:
WebSocket closed with code 1011: InternalServerError
_app-62f3ee54ceeb705a.js:4 Attempting reconnect in 51.837452158347006ms
_app-62f3ee54ceeb705a.js:4 WebSocket reconnected
_app-62f3ee54ceeb705a.js:4 WebSocket closed with code 1011: InternalServerError
_app-62f3ee54ceeb705a.js:4 Attempting reconnect in 67.02649050867504ms
_app-62f3ee54ceeb705a.js:4 WebSocket reconnected


I'm accessing this function from the convex dashboard:
export const testsearch = query({
  args: {
    query: v.optional(v.string()),
  },
  handler: async (ctx, { query }) => {
    if (query && query.length > 0) {
      return ctx.db
        .query("partModel")
        .withSearchIndex("search_component", (q) =>
          q.search("component", query),
        )
        .collect();
    } else {
      return ctx.db.query("partModel").collect();
    }
  },
});

When not providing a query the result is as expected. When providing a query string, the UI keeps loading forever and console shows above errors.
Was this page helpful?