{"record":{"id":"95f7a2fc2b9d5fe6","repo":"denoland/deno","slug":"cannot-get-cursor-before-first-iteration","errorCode":null,"errorMessage":"Cannot get cursor before first iteration","messagePattern":"Cannot get cursor before first iteration","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ext/kv/01_db.ts","lineNumber":904,"sourceCode":"        this.#selector = { start, end };\n      } else {\n        throw new TypeError(\n          \"Selector must specify either 'prefix' or both 'start' and 'end' key\",\n        );\n      }\n    }\n    ObjectFreeze(this.#selector);\n    this.#pullBatch = pullBatch;\n    this.#limit = limit;\n    this.#reverse = reverse;\n    this.#consistency = consistency;\n    this.#batchSize = batchSize;\n    this.#cursorGen = cursor ? () => cursor : null;\n  }\n\n  get cursor(): string {\n    if (this.#cursorGen === null) {\n      throw new Error(\"Cannot get cursor before first iteration\");\n    }\n\n    return this.#cursorGen();\n  }\n\n  async next(): Promise<IteratorResult<Deno.KvEntry<unknown>>> {\n    // Fused or limit exceeded\n    if (\n      this.#done ||\n      (this.#limit !== undefined && this.#count >= this.#limit)\n    ) {\n      return { done: true, value: undefined };\n    }\n\n    // Attempt to fill the buffer\n    if (!this.#entries?.length && !this.#lastBatch) {\n      const batch = await this.#pullBatch(\n        this.#selector,","sourceCodeStart":886,"sourceCodeEnd":922,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/ext/kv/01_db.ts#L886-L922","documentation":"Error \"Cannot get cursor before first iteration\" thrown in denoland/deno.","triggerScenarios":"Thrown at ext/kv/01_db.ts:904 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}