sveltejs/kit · error

query.live '${__.name}' did not yield a value

Error message

query.live '${__.name}' did not yield a value

What it means

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.

Source

Thrown at packages/kit/src/runtime/app/server/remote/query.js:523

}

/**
 * @param {RemoteQueryLiveInternals} __
 * @param {string} payload — the stringified raw argument (i.e. the cache key the client will use)
 * @param {RequestEvent} event
 * @param {RequestState} state
 * @param {() => AsyncGenerator<any, void, void>} get_generator
 * @returns {RemoteLiveQuery<any>}
 */
function create_live_query_resource(__, payload, event, state, get_generator) {
	/** @type {Promise<any> | null} */
	let promise = null;

	const get_first_value = async () => {
		for await (const value of get_generator()) {
			return value;
		}
		throw new Error(`query.live '${__.name}' did not yield a value`);
	};

	const get_promise = () => {
		return (promise ??= get_response(__, payload, state, get_first_value));
	};

	const populate_hydratable = () => {
		if (__.id && state.is_in_render) {
			// swallow rejections so they don't crash the server — the error is
			// serialized into the response and surfaced on the client instead
			get_promise().catch(noop);
		}
	};

	return {
		/** @type {Promise<any>['catch']} */
		catch(onrejected) {
			return get_promise().catch(onrejected);

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Ensure the live query generator always yields at least one value before completing
  2. Throw a descriptive error instead of returning early when no data is available
  3. Check the generator's source (e.g. event emitter/SSE) isn't closing instantly
  4. Add a fallback initial yield for empty states

Example fix

// before
export const getUpdates = query.live(async function* (id) {
  if (!source(id)) return; // may yield nothing
});
// after
export const getUpdates = query.live(async function* (id) {
  const src = source(id);
  if (!src) throw new Error('no update source for ' + id);
  yield await src.current();
  for await (const v of src.stream()) yield v;
});
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

try {
  const value = await resource;
} catch (e) {
  if (String(e).includes('did not yield a value')) {
    // provide fallback/initial data
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02). Data as JSON: /api/errors/578655efd13b2aa5. Report an issue: GitHub.