{"record":{"id":"ed6e8d9ab804b09e","repo":"hcengineering/platform","slug":"measure-slow-findall","errorCode":null,"errorMessage":"measure slow findAll","messagePattern":"measure slow findAll","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"plugins/client-resources/src/connection.ts","lineNumber":780,"sourceCode":"\n  getAccount (): Promise<Account> {\n    if (this.account !== undefined) {\n      return Promise.resolve(clone(this.account))\n    }\n    return this.sendRequest({ method: 'getAccount', params: [] })\n  }\n\n  async findAll<T extends Doc>(\n    _class: Ref<Class<T>>,\n    query: DocumentQuery<T>,\n    options?: FindOptions<T>\n  ): Promise<FindResult<T>> {\n    const result = await this.sendRequest({\n      method: 'findAll',\n      params: [_class, query, options],\n      measure: (time, result, serverTime, queue, toReceive) => {\n        if (typeof window !== 'undefined' && (time > 1000 || serverTime > 500)) {\n          console.warn(\n            'measure slow findAll',\n            time,\n            serverTime,\n            toReceive,\n            queue,\n            _class,\n            query,\n            options,\n            result,\n            JSON.stringify(result).length\n          )\n        }\n      }\n    })\n    if (result.lookupMap !== undefined) {\n      // We need to extract lookup map to document lookups\n      for (const d of result) {\n        if (d.$lookup !== undefined) {","sourceCodeStart":762,"sourceCodeEnd":798,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/plugins/client-resources/src/connection.ts#L762-L798","documentation":"The client-resources connection's findAll sends a 'findAll' request and measures round-trip time via the measure callback. If the total time exceeds 1000ms or the server-side execution time exceeds 500ms (browser only), it warns 'measure slow findAll' with a timing breakdown (time, serverTime, toReceive, queue) and the queried _class. It is a performance diagnostic, not an error - the query still succeeds.","triggerScenarios":"Any findAll call through this connection where (time > 1000 || serverTime > 500) in a browser context: slow query execution server-side, large result sets, or long client-side queueing/network latency.","commonSituations":"Queries on large classes without limiting options (no limit/projection); missing DB indexes; cold caches after deployment; chatty client code issuing heavy findAll on UI load; slow network links inflating total time.","solutions":["Pass query options (limit, sort) to findAll to bound result size for large classes.","Add/optimize database indexes for the queried _class and its filter fields.","Check serverTime vs time in the warning: high serverTime means fix the query/index; high total time only means investigate network/queue latency.","Profile the calling code - batch or cache repeated heavy findAll calls."],"exampleFix":"// before\nconst result = await client.findAll(task.class.Task, { done: false })\n// after\nconst result = await client.findAll(task.class.Task, { done: false }, { limit: 100, sort: { modifiedOn: -1 } }) // bounded, indexed query","handlingStrategy":"fallback","validationCode":"// Bound the query before issuing findAll\nconst options = { limit: 100, sort: { modifiedOn: SortingOrder.Descending } }\nawait client.findAll(task.class.Task, query, options)\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass limit/sort options on large classes.","Add indexes for frequently queried classes.","If warnings persist with high serverTime, escalate the query for backend optimization; high total time only points to network/queue issues."],"tags":["performance","query","database","latency"],"backgroundTag":"slow-findall-query","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}