sveltejs/kit · error
requested(${__.name}, ${limit}) cannot be used with synchron
Error message
requested(${__.name}, ${limit}) cannot be used with synchronous iteration because the query validator is async. Use `for await ... of` instead What it means
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.
Source
Thrown at packages/kit/src/runtime/app/server/remote/requested.js:174
const promise = Promise.reject(error);
promise.catch(noop);
get_cache(__, state)[payload] = promise;
refresh(event, state, __, payload, () => promise);
};
for (const payload of skipped) consume(payload);
const result = {
*[Symbol.iterator]() {
for (const payload of selected) {
consume(payload);
try {
const parsed = parse_remote_arg(payload);
const validated = __.validate(parsed);
if (is_thenable(validated)) {
throw new Error(
// TODO improve
`requested(${__.name}, ${limit}) cannot be used with synchronous iteration because the query validator is async. Use \`for await ... of\` instead`
);
}
yield {
arg: validated,
query: __.bind(payload, validated),
ignore: create_ignore(payload)
};
} catch (error) {
record_failure(payload, error);
continue;
}
}
},
async *[Symbol.asyncIterator]() {
yield* race_all(selected, async (payload) => {View on GitHub (pinned to 03f1687fe6)
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
Example fix
// before
for (const item of requested(getPosts, 5)) { /* throws */ }
// after
for await (const item of requested(getPosts, 5)) { /* ok */ } Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
try {
for await (const item of requested(q, limit)) {
consume(item);
}
} catch (e) {
// handle per-item errors during async iteration
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: Using async validation libraries (Zod async schemas, class-validator) in the query; switching a validator from sync to async after adding requested() iteration.
Related errors
- requested(...) expects a query function created with query(.
- Cannot call query '${__.name}' while prerendering, as preren
- Cannot call '${__.name}.withOverride()' on the server
- query.live '${__.name}' did not yield a value
- requested(...) can only be called in the context of a comman
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/b7e22755c7724930.
Report an issue: GitHub.