{"record":{"id":"b7e22755c7724930","repo":"sveltejs/kit","slug":"requested-name-limit-cannot-be-used-wit","errorCode":null,"errorMessage":"requested(${__.name}, ${limit}) cannot be used with synchronous iteration because the query validator is async. Use `for await ... of` instead","messagePattern":"requested\\((.+?), (.+?)\\) cannot be used with synchronous iteration because the query validator is async\\. Use `for await \\.\\.\\. of` instead","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/kit/src/runtime/app/server/remote/requested.js","lineNumber":174,"sourceCode":"\t\tconst promise = Promise.reject(error);\n\t\tpromise.catch(noop);\n\n\t\tget_cache(__, state)[payload] = promise;\n\t\trefresh(event, state, __, payload, () => promise);\n\t};\n\n\tfor (const payload of skipped) consume(payload);\n\n\tconst result = {\n\t\t*[Symbol.iterator]() {\n\t\t\tfor (const payload of selected) {\n\t\t\t\tconsume(payload);\n\t\t\t\ttry {\n\t\t\t\t\tconst parsed = parse_remote_arg(payload);\n\t\t\t\t\tconst validated = __.validate(parsed);\n\n\t\t\t\t\tif (is_thenable(validated)) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t// TODO improve\n\t\t\t\t\t\t\t`requested(${__.name}, ${limit}) cannot be used with synchronous iteration because the query validator is async. Use \\`for await ... of\\` instead`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tyield {\n\t\t\t\t\t\targ: validated,\n\t\t\t\t\t\tquery: __.bind(payload, validated),\n\t\t\t\t\t\tignore: create_ignore(payload)\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\trecord_failure(payload, error);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tasync *[Symbol.asyncIterator]() {\n\t\t\tyield* race_all(selected, async (payload) => {","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/app/server/remote/requested.js#L156-L192","documentation":"requested() with a numeric limit supports iteration over tracked query payloads. If the query's validator returns a promise (is thenable), synchronous for...of cannot consume it, so this error directs you to async iteration.","triggerScenarios":"Iterating requested(query, limit) with for...of when the query's validate function is async or returns a Promise (e.g. schema validators returning promises, async Zod refinements).","commonSituations":"Using async validation libraries (Zod async schemas, class-validator) in the query; switching a validator from sync to async after adding requested() iteration.","solutions":["Use for await (const item of requested(q, limit)) instead of for...of","Make the query validator synchronous so sync iteration works","Pre-validate the payload synchronously and keep validate non-async"],"exampleFix":"// before\nfor (const item of requested(getPosts, 5)) { /* throws */ }\n// after\nfor await (const item of requested(getPosts, 5)) { /* ok */ }","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  for await (const item of requested(q, limit)) {\n    consume(item);\n  }\n} catch (e) {\n  // handle per-item errors during async iteration\n}","preventionTips":["Prefer for await...of when iterating requested(...) with a limit","Keep query validators synchronous if sync iteration is needed","Audit async schema validators in query definitions"],"tags":["async-iteration","requested","query","validator"],"backgroundTag":"async-validator-sync-iteration","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}