{"record":{"id":"578655efd13b2aa5","repo":"sveltejs/kit","slug":"query-live-name-did-not-yield-a-value","errorCode":null,"errorMessage":"query.live '${__.name}' did not yield a value","messagePattern":"query\\.live '(.+?)' did not yield a value","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/kit/src/runtime/app/server/remote/query.js","lineNumber":523,"sourceCode":"}\n\n/**\n * @param {RemoteQueryLiveInternals} __\n * @param {string} payload — the stringified raw argument (i.e. the cache key the client will use)\n * @param {RequestEvent} event\n * @param {RequestState} state\n * @param {() => AsyncGenerator<any, void, void>} get_generator\n * @returns {RemoteLiveQuery<any>}\n */\nfunction create_live_query_resource(__, payload, event, state, get_generator) {\n\t/** @type {Promise<any> | null} */\n\tlet promise = null;\n\n\tconst get_first_value = async () => {\n\t\tfor await (const value of get_generator()) {\n\t\t\treturn value;\n\t\t}\n\t\tthrow new Error(`query.live '${__.name}' did not yield a value`);\n\t};\n\n\tconst get_promise = () => {\n\t\treturn (promise ??= get_response(__, payload, state, get_first_value));\n\t};\n\n\tconst populate_hydratable = () => {\n\t\tif (__.id && state.is_in_render) {\n\t\t\t// swallow rejections so they don't crash the server — the error is\n\t\t\t// serialized into the response and surfaced on the client instead\n\t\t\tget_promise().catch(noop);\n\t\t}\n\t};\n\n\treturn {\n\t\t/** @type {Promise<any>['catch']} */\n\t\tcatch(onrejected) {\n\t\t\treturn get_promise().catch(onrejected);","sourceCodeStart":505,"sourceCodeEnd":541,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/app/server/remote/query.js#L505-L541","documentation":"A live query's first value is obtained by iterating its async generator; if the generator completes without yielding any value, this error throws because there is nothing to resolve the resource promise with.","triggerScenarios":"A query.live generator function returns/ends immediately (e.g. an early return, empty source, or a condition that skips all yields) and the server tries to extract the first value.","commonSituations":"Live query implementations with guards like if (!ready) return; generators driven by event sources that close immediately; errors swallowed upstream causing the generator to terminate silently.","solutions":["Ensure the live query generator always yields at least one value before completing","Throw a descriptive error instead of returning early when no data is available","Check the generator's source (e.g. event emitter/SSE) isn't closing instantly","Add a fallback initial yield for empty states"],"exampleFix":"// before\nexport const getUpdates = query.live(async function* (id) {\n  if (!source(id)) return; // may yield nothing\n});\n// after\nexport const getUpdates = query.live(async function* (id) {\n  const src = source(id);\n  if (!src) throw new Error('no update source for ' + id);\n  yield await src.current();\n  for await (const v of src.stream()) yield v;\n});","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  const value = await resource;\n} catch (e) {\n  if (String(e).includes('did not yield a value')) {\n    // provide fallback/initial data\n  }\n}","preventionTips":["Ensure live query generators always yield at least one value","Avoid early returns in generator implementations","Handle generator source closures gracefully"],"tags":["live-query","generator","async-iteration","remote-functions"],"backgroundTag":"async-generator-yield-missing","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}