{"record":{"id":"337e8debb547fd30","repo":"sveltejs/kit","slug":"requested-expects-a-query-function-created-wi","errorCode":null,"errorMessage":"requested(...) expects a query function created with query(...), query.batch(...), or query.live(...)","messagePattern":"requested\\(\\.\\.\\.\\) expects a query function created with query\\(\\.\\.\\.\\), query\\.batch\\(\\.\\.\\.\\), or query\\.live\\(\\.\\.\\.\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/kit/src/runtime/app/server/remote/requested.js","lineNumber":114,"sourceCode":" * @template Input\n * @template Output\n * @template [Validated=Input]\n * @param {RemoteQueryFunction<Input, Output, Validated> | RemoteLiveQueryFunction<Input, Output, Validated>} query\n * @param {number} limit\n * @returns {RequestedResult<Validated, Output>}\n */\nexport function requested(query, limit) {\n\tconst { event, state } = get_request_store();\n\tconst internals = /** @type {RemoteAnyQueryInternals | undefined} */ (\n\t\t/** @type {any} */ (query).__\n\t);\n\n\tif (\n\t\tinternals?.type !== 'query' &&\n\t\tinternals?.type !== 'query_batch' &&\n\t\tinternals?.type !== 'query_live'\n\t) {\n\t\tthrow new Error(\n\t\t\t'requested(...) expects a query function created with query(...), query.batch(...), or query.live(...)'\n\t\t);\n\t}\n\n\t// narrow-stable alias so generator closures below don't lose the narrowing\n\tconst __ = internals;\n\n\tconst requested = state.remote.requested;\n\tconst payloads = requested?.get(__.id) ?? new Set();\n\tconst ignored = (state.remote.ignored ??= new Set());\n\n\t/** @param {string} payload */\n\tconst consume = (payload) => {\n\t\tpayloads.delete(payload);\n\t\tif (payloads.size === 0) requested?.delete(__.id);\n\t};\n\n\t/** @param {string} payload */","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/app/server/remote/requested.js#L96-L132","documentation":"requested() exposes results of queries tracked inside a command/form remote function, so the first argument must be a query function carrying internals of type query, query_batch, or query_live. Anything else fails this check.","triggerScenarios":"Passing a non-query function (a plain server function, command, form action, or arbitrary object) as the first argument to requested(...) inside a command/form.","commonSituations":"Typo importing the query; accidentally passing the command itself to requested(); calling requested() with an older module whose exports were refactored away from query().","solutions":["Pass only functions created with query(...), query.batch(...), or query.live(...) to requested(...)","Check imports so the correct query module is referenced","If you need command results, read the command's return value directly instead of requested()"],"exampleFix":"// before\nconst rows = await requested(myCommand, 5); // command, not query\n// after\nconst rows = await requested(myQuery, 5);","handlingStrategy":"type-guard","validationCode":"if (typeof fn !== 'function' || fn.__?.type !== 'query') {\n  throw new TypeError('expected a query() function');\n}","typeGuard":"function isQueryFn(fn) {\n  return typeof fn === 'function' &&\n    (fn.__?.type === 'query' || fn.__?.type === 'query_batch' || fn.__?.type === 'query_live');\n}","tryCatchPattern":"try {\n  const items = await requested(maybeQuery, 5);\n} catch (e) {\n  if (!isQueryFn(maybeQuery)) throw new TypeError('pass a query() function');\n  throw e;\n}","preventionTips":["Only pass query()/query.batch()/query.live() results to requested()","Verify import paths for query modules","Type-check arguments with JSDoc/TS"],"tags":["remote-functions","query","requested","type-mismatch"],"backgroundTag":"invalid-argument-value","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}