Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Accessing an async derived in a derived declared before the async derived throws an un-descriptive error | GoodFirstPicks

Accessing an async derived in a derived declared before the async derived throws an un-descriptive error

sveltejs/svelte 2 comments 1mo ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeSvelteTypeScript

Why this is a good first issue

The issue involves async behavior and initialization order, which requires understanding Svelte's internals.

AI Summary

The issue involves accessing an async derived value before it is initialized, leading to an undescriptive error. The problem requires understanding Svelte's rendering order and async behavior. The scope is somewhat clear, but the solution might involve deeper changes to how derived values are handled.

Issue Description

Describe the bug

This code

<script>
	function get(){
		return b;
	}
	const a = $derived(get());
	const b = $derived(await 42);
</script>

{a}

throws a Cannot read properties of undefined (reading 'f') in <unknown> in __wrapper.svelte

because when it tries to get b since b it's an async derived it's not initialized yet by the time the function for a executes. We should at least throw a more descriptive error (or possibly fix this).

Reproduction

REPL

Logs

System Info

repl

Severity

annoyance

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!

Risk Flags

  • async behavior
  • order of initialization
Loading labels...

Details

Points10 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno