Skip to content

feat: allow await in components #15844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 621 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
621 commits
Select commit Hold shift + click to select a range
a98b5ea
note to self
Rich-Harris May 3, 2025
fc18e26
failing test
Rich-Harris May 3, 2025
ed17212
fix
Rich-Harris May 3, 2025
78dd1e2
DRY
Rich-Harris May 3, 2025
13a9b70
failing test for linear order
Rich-Harris May 3, 2025
1dd383e
enforce linear order
Rich-Harris May 3, 2025
7762f29
update test
Rich-Harris May 4, 2025
8baf164
fix
Rich-Harris May 4, 2025
666a148
implement getAbortSignal
Rich-Harris May 4, 2025
357ff47
docs
Rich-Harris May 4, 2025
b61c6ad
fix
Rich-Harris May 4, 2025
b68dcdc
note to self
Rich-Harris May 4, 2025
5e8bcfa
tweak/fix
Rich-Harris May 4, 2025
3d0b6f7
update test
Rich-Harris May 4, 2025
48a781e
fix
Rich-Harris May 5, 2025
693262a
fix
Rich-Harris May 5, 2025
c599807
implement `settled`
Rich-Harris May 9, 2025
53b9b8f
merge main
Rich-Harris May 20, 2025
29406c9
merge main
Rich-Harris May 28, 2025
449ca14
merge main
Rich-Harris May 29, 2025
c72d091
oops
Rich-Harris May 29, 2025
95b9605
fix
Rich-Harris May 29, 2025
6625971
work around some quirk of the test environment
Rich-Harris May 30, 2025
15ea2df
Merge branch 'main' into async
Rich-Harris May 30, 2025
4136cf2
fix
Rich-Harris May 31, 2025
fcd51d4
tidy up
Rich-Harris May 31, 2025
f584d0d
fix
Rich-Harris May 31, 2025
7dc2019
lint
Rich-Harris May 31, 2025
a2bc5f7
add flag
Rich-Harris May 31, 2025
bc050c3
make everything non-breaking for people who dont opt in
Rich-Harris May 31, 2025
4d05ed1
disallow late setContext calls
Rich-Harris May 31, 2025
9b1e182
another test
Rich-Harris May 31, 2025
eaaee83
regenerate
Rich-Harris May 31, 2025
7e83cda
move
Rich-Harris May 31, 2025
2071160
keep order
Rich-Harris Jun 1, 2025
1a094e7
lint
Rich-Harris Jun 1, 2025
03273b7
chore: better HTML normalization test helper
Rich-Harris Jun 1, 2025
7c10b23
simplify
Rich-Harris Jun 1, 2025
73796c4
simplify/robustify
Rich-Harris Jun 1, 2025
3cf0b9e
Merge branch 'better-normalize-html' into async
Rich-Harris Jun 1, 2025
302dff2
don't write values to deriveds when time travelling
Rich-Harris Jun 2, 2025
b608ee2
add failing test
Rich-Harris Jun 3, 2025
1a42fc8
fix
Rich-Harris Jun 4, 2025
f72d1a6
merge
Rich-Harris Jun 4, 2025
8557077
we can remove this now
Rich-Harris Jun 4, 2025
c96d310
failing test
Rich-Harris Jun 4, 2025
17b2f22
fix
Rich-Harris Jun 4, 2025
d131e28
unused
Rich-Harris Jun 4, 2025
f8e4651
failing test
Rich-Harris Jun 4, 2025
fdb7a6d
fix
Rich-Harris Jun 4, 2025
23bd5c2
DRY
Rich-Harris Jun 4, 2025
00ba548
simplify
Rich-Harris Jun 4, 2025
cd24e51
tweak
Rich-Harris Jun 4, 2025
c8e47cc
tidy
Rich-Harris Jun 4, 2025
7f0072b
tidy
Rich-Harris Jun 4, 2025
dfa8d6b
yes it can, apparently
Rich-Harris Jun 4, 2025
aec7368
tidy up
Rich-Harris Jun 4, 2025
541ab97
unused
Rich-Harris Jun 4, 2025
b1960ce
complete merge
Rich-Harris Jun 5, 2025
37333df
WIP
Rich-Harris Jun 5, 2025
42d5c7e
simplify
Rich-Harris Jun 5, 2025
54e720b
merge
Rich-Harris Jun 5, 2025
0530c2c
debugging help
Rich-Harris Jun 5, 2025
c3ad8c4
WIP
Rich-Harris Jun 5, 2025
f3b7ce0
unused
Rich-Harris Jun 5, 2025
6cd7ef9
partial merge
Rich-Harris Jun 6, 2025
84e0790
merge main
Rich-Harris Jun 6, 2025
520d893
WIP
Rich-Harris Jun 6, 2025
c566d56
WIP
Rich-Harris Jun 6, 2025
60f8653
fix
Rich-Harris Jun 6, 2025
858dc35
add test
Rich-Harris Jun 6, 2025
68e2eee
rename
Rich-Harris Jun 6, 2025
5a05dc5
fix
Rich-Harris Jun 6, 2025
0bd5310
unused
Rich-Harris Jun 8, 2025
bc1a4ca
oops
Rich-Harris Jun 8, 2025
fe6c00d
merge main
Rich-Harris Jun 10, 2025
6e1c89f
merge main
Rich-Harris Jun 11, 2025
8733a5d
Merge branch 'main' into async
Rich-Harris Jun 12, 2025
1fb0b1f
merge main
Rich-Harris Jun 14, 2025
6efdc23
merge main
Rich-Harris Jun 15, 2025
61a11a5
chore: merge main into async branch (#16197)
dummdidumm Jun 18, 2025
3156a24
merge main
Rich-Harris Jun 24, 2025
5fda011
make batch.#deferred private
Rich-Harris Jun 24, 2025
ea0e269
fix settled when awaits occur inside pending boundary
Rich-Harris Jun 24, 2025
6b9f860
tweak
Rich-Harris Jun 24, 2025
66635c5
change behaviour of `tick()` to be requestAnimationFrame-based
Rich-Harris Jun 24, 2025
8d20a9a
get rid of a bunch of Promise.resolve chains
Rich-Harris Jun 24, 2025
2ae79f3
more
Rich-Harris Jun 24, 2025
0be1f6a
more
Rich-Harris Jun 24, 2025
680cb6a
Merge branch 'main' into async
Rich-Harris Jun 25, 2025
ac7b4a7
Merge branch 'main' into async
Rich-Harris Jun 25, 2025
e912f88
fix test
Rich-Harris Jun 25, 2025
0430c76
disallow `flushSync()` inside effects
Rich-Harris Jun 25, 2025
b400780
regenerate
Rich-Harris Jun 25, 2025
951d8e6
handle errors in block expressions
Rich-Harris Jun 25, 2025
fdd009b
make validate_each_keys async-aware
dummdidumm Jun 25, 2025
5c0a4a0
for unowned deriveds, throw errors lazily
Rich-Harris Jun 25, 2025
a0dba34
rename ASYNC_ERROR -> ERROR_VALUE, and avoid conflicts with other fla…
Rich-Harris Jun 25, 2025
da5b74a
invoke boundary directly
Rich-Harris Jun 25, 2025
c80d165
local effect pending
Rich-Harris Jun 25, 2025
ee21d9f
update test
Rich-Harris Jun 25, 2025
516ab3b
Merge branch 'async' into async-local-effect-pending
Rich-Harris Jun 25, 2025
8cd5635
fix
Rich-Harris Jun 25, 2025
8300327
fix
Rich-Harris Jun 25, 2025
c04a13b
fix weird bug in tests
Rich-Harris Jun 26, 2025
8a1ab92
Merge branch 'async-local-effect-pending' into async
Rich-Harris Jun 26, 2025
5c1ff99
delete old changeset that somehow got left over here
Rich-Harris Jun 26, 2025
042598c
Update .changeset/eleven-weeks-dance.md
Rich-Harris Jun 26, 2025
758c39d
update error details
Rich-Harris Jun 26, 2025
163009d
unused
Rich-Harris Jun 26, 2025
2961124
simplify
Rich-Harris Jun 26, 2025
f388568
tweak
Rich-Harris Jun 26, 2025
f34f28e
tweak
Rich-Harris Jun 26, 2025
1e2e57f
tweak
Rich-Harris Jun 26, 2025
a01249e
tweak
Rich-Harris Jun 26, 2025
2c2557a
tidy up
Rich-Harris Jun 26, 2025
2fd7628
handle errors in async block expressions
Rich-Harris Jun 26, 2025
5694c06
tweak
Rich-Harris Jun 26, 2025
591aeb0
groundwork for async attribute_effect
Rich-Harris Jun 26, 2025
7144f11
dry out
Rich-Harris Jun 26, 2025
d7a99b6
fix async directives
Rich-Harris Jun 26, 2025
650144a
tidy up
Rich-Harris Jun 26, 2025
334adc0
initialize option values before initing select values
Rich-Harris Jun 26, 2025
d89f318
simplify init_select
Rich-Harris Jun 26, 2025
58918e3
simplify
Rich-Harris Jun 26, 2025
38d458a
tweak
Rich-Harris Jun 26, 2025
39b7f41
tidy up
Rich-Harris Jun 26, 2025
5615fd3
tweak
Rich-Harris Jun 26, 2025
b459bb0
on second thoughts just simplify it here
Rich-Harris Jun 26, 2025
0c4af38
merge
Rich-Harris Jun 26, 2025
3070b9a
tidy
Rich-Harris Jun 26, 2025
336a526
merge main
Rich-Harris Jun 27, 2025
a018796
handle awaits in `<slot>`
Rich-Harris Jun 27, 2025
94d74f2
unused
Rich-Harris Jun 27, 2025
0c24129
tidy up
Rich-Harris Jun 27, 2025
12fffb9
tidy up
Rich-Harris Jun 27, 2025
2b44100
dry out
Rich-Harris Jun 27, 2025
2585516
dry out
Rich-Harris Jun 27, 2025
3eee9d5
Revert "dry out"
Rich-Harris Jun 27, 2025
7d6b603
dry out
Rich-Harris Jun 27, 2025
7bbb640
dry out
Rich-Harris Jun 27, 2025
a1a289e
use let for block-scoped stuff
Rich-Harris Jun 27, 2025
97f8110
dry out
Rich-Harris Jun 27, 2025
53137a1
dry out
Rich-Harris Jun 27, 2025
b3bcdaf
tidy up
Rich-Harris Jun 27, 2025
aa14305
only wrap awaits in `$.save` when necessary
Rich-Harris Jun 27, 2025
1c66278
oops
Rich-Harris Jun 27, 2025
88b9fdb
Merge branch 'main' into async
dummdidumm Jun 28, 2025
1a6cd7d
merge main
Rich-Harris Jun 30, 2025
aff0f50
merge main
Rich-Harris Jun 30, 2025
4d05b1b
remove TODO comment (just checked)
Rich-Harris Jun 30, 2025
73fb7a1
oops, leftover
Rich-Harris Jun 30, 2025
80de2ca
simplify
Rich-Harris Jun 30, 2025
ff0662a
unused
Rich-Harris Jun 30, 2025
e2bcd8c
remove logging
Rich-Harris Jun 30, 2025
2e854de
tweak
Rich-Harris Jun 30, 2025
f6976fd
unused
Rich-Harris Jun 30, 2025
9386b77
unused
Rich-Harris Jun 30, 2025
d96991a
remove logging
Rich-Harris Jul 1, 2025
36947c5
partial fix
Rich-Harris Jul 1, 2025
923d8f6
fix
Rich-Harris Jul 1, 2025
09792a0
merge main
Rich-Harris Jul 1, 2025
a5288ea
merge main
Rich-Harris Jul 2, 2025
56b0e30
remove unused EFFECT_HAS_DERIVED
Rich-Harris Jul 2, 2025
89b93a1
merge
Rich-Harris Jul 2, 2025
4757b1b
Update packages/svelte/src/reactivity/create-subscriber.js
Rich-Harris Jul 2, 2025
31f9eb9
Update packages/svelte/src/index-client.js
Rich-Harris Jul 2, 2025
d7163e6
Update packages/svelte/src/internal/client/runtime.js
Rich-Harris Jul 2, 2025
379526b
unused
Rich-Harris Jul 2, 2025
7d15dd3
Merge branch 'async' of github.com:sveltejs/svelte into async
Rich-Harris Jul 2, 2025
9165bd0
merge
Rich-Harris Jul 2, 2025
29076b0
Update packages/svelte/src/internal/client/reactivity/sources.js
Rich-Harris Jul 2, 2025
6339aaf
Update packages/svelte/src/internal/client/reactivity/deriveds.js
Rich-Harris Jul 2, 2025
4e9822d
Update packages/svelte/src/internal/client/reactivity/deriveds.js
Rich-Harris Jul 2, 2025
1e7e9fa
prettier
Rich-Harris Jul 2, 2025
f3930eb
unused
Rich-Harris Jul 2, 2025
5c2f77f
fix flags
Rich-Harris Jul 2, 2025
bbb694b
tweak
Rich-Harris Jul 2, 2025
6394da7
tweak
Rich-Harris Jul 2, 2025
433da2b
merge main
Rich-Harris Jul 2, 2025
a100bdc
unused
Rich-Harris Jul 2, 2025
70a01fc
fix
Rich-Harris Jul 2, 2025
36a9059
no idea what a 'boundary micro task' is or why it was deemed necessar…
Rich-Harris Jul 2, 2025
a678030
remove queue_boundary_micro_task
Rich-Harris Jul 2, 2025
1bf4949
oops
Rich-Harris Jul 2, 2025
8ba64c0
note
Rich-Harris Jul 2, 2025
9bedb7f
tidy up
Rich-Harris Jul 2, 2025
636c809
remove TODO
Rich-Harris Jul 2, 2025
8ffa726
make method private
Rich-Harris Jul 2, 2025
c028371
simplify
Rich-Harris Jul 2, 2025
7a08d9b
flesh out await_reactivity_loss warning
Rich-Harris Jul 3, 2025
1626c22
tweak
Rich-Harris Jul 3, 2025
beaae35
update test
Rich-Harris Jul 3, 2025
cda99a1
fix
Rich-Harris Jul 3, 2025
94415f0
null out from_async_derived in more places
Rich-Harris Jul 3, 2025
77b4f56
tidy up test
Rich-Harris Jul 3, 2025
2629561
failing test
Rich-Harris Jul 3, 2025
1d0a945
merge main
Rich-Harris Jul 3, 2025
9c13fef
unused
Rich-Harris Jul 3, 2025
70c9f4b
fix test
Rich-Harris Jul 3, 2025
f043519
fix
Rich-Harris Jul 3, 2025
c78e8e0
simplify. no idea what the async_mode_flag stuff is about, but it app…
Rich-Harris Jul 3, 2025
c268124
add async_derived_orphan error
Rich-Harris Jul 3, 2025
b78dd16
regenerate
Rich-Harris Jul 3, 2025
e888b5b
flesh out await_outside_boundary message
Rich-Harris Jul 3, 2025
cf2bdd1
add some JSDoc
Rich-Harris Jul 3, 2025
6b1ac77
only update `$effect.pending()` if someone is listening, since it cau…
Rich-Harris Jul 3, 2025
c3aabc1
tweak logic to make it clearer why and when we commit a batch
Rich-Harris Jul 3, 2025
2325a5a
add a couple of comments
Rich-Harris Jul 3, 2025
b61a081
Merge branch 'main' into async
Rich-Harris Jul 5, 2025
8a24558
false -> 0
Rich-Harris Jul 5, 2025
2f531a4
add comment
Rich-Harris Jul 5, 2025
06d2886
unused
Rich-Harris Jul 5, 2025
70d4a3d
silence warning
Rich-Harris Jul 5, 2025
4fc61c7
add effect_pending_outside_reaction error
Rich-Harris Jul 5, 2025
3e17010
Update packages/svelte/src/compiler/types/index.d.ts
Rich-Harris Jul 5, 2025
983083f
suspend batch, not boundary
Rich-Harris Jul 5, 2025
d39e60b
rename from_async_derived -> current_async_derived
Rich-Harris Jul 5, 2025
54e3925
tweak
Rich-Harris Jul 5, 2025
f991d9d
remove TODO - this method is only called when pending snippet exists
Rich-Harris Jul 5, 2025
f0bb8dd
use error boundary for test - vitest does some weird error swallowing…
Rich-Harris Jul 6, 2025
5e1ec58
flush less often
Rich-Harris Jul 6, 2025
aa5af75
restore -> activate
Rich-Harris Jul 6, 2025
c83374c
remove TODO
Rich-Harris Jul 6, 2025
ec21b74
move batch-related code into batch.js
Rich-Harris Jul 6, 2025
bf9e109
make flush_queued_root_effects a method of batch
Rich-Harris Jul 7, 2025
0c5b4d8
make process_effects a method of batch
Rich-Harris Jul 7, 2025
c7c9404
make stuff private
Rich-Harris Jul 7, 2025
497ef13
unused
Rich-Harris Jul 7, 2025
2460370
merge main
Rich-Harris Jul 7, 2025
d7659d5
regenerate
Rich-Harris Jul 7, 2025
e13b0d9
merge main
Rich-Harris Jul 7, 2025
da83c85
merge main
Rich-Harris Jul 7, 2025
52a95a0
update test
Rich-Harris Jul 7, 2025
6169405
more JSDoc
Rich-Harris Jul 8, 2025
76b8d52
add more JSDoc
Rich-Harris Jul 8, 2025
3f3734b
branch and block effects do not also need to be render effects
Rich-Harris Jul 8, 2025
ee3a02a
tidy up
Rich-Harris Jul 8, 2025
8b8f059
simplify
Rich-Harris Jul 8, 2025
fa1deac
unused
Rich-Harris Jul 8, 2025
6f12c09
move code where it belongs
Rich-Harris Jul 8, 2025
d367052
remove, for now
Rich-Harris Jul 8, 2025
c79553b
fix
Rich-Harris Jul 8, 2025
6c2064b
only apply error adjustments when error escapes boundaries
Rich-Harris Jul 8, 2025
179980e
remove EFFECT_IS_UPDATING
Rich-Harris Jul 8, 2025
2019451
is_dirty is a better name than check_dirtiness
Rich-Harris Jul 8, 2025
f6358d5
duplicates are rare and harmless
Rich-Harris Jul 8, 2025
11f2c48
apparently we no longer need the merging logic? we can simplify and f…
Rich-Harris Jul 8, 2025
39a7f08
tidy
Rich-Harris Jul 8, 2025
60eaa28
don't commit stale batches
Rich-Harris Jul 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
more
  • Loading branch information
Rich-Harris committed Apr 20, 2025
commit e247f665af47c1508539cde800230a03863b9c65
2 changes: 2 additions & 0 deletions packages/svelte/src/internal/client/dom/blocks/boundary.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { queue_boundary_micro_task } from '../task.js';
import * as e from '../../../shared/errors.js';
import { DEV } from 'esm-env';
import { from_async_derived, set_from_async_derived } from '../../reactivity/deriveds.js';
import { active_fork, Fork } from '../../reactivity/forks.js';

/**
* @typedef {{
Expand Down Expand Up @@ -114,6 +115,7 @@ export class Boundary {
// boundary, and hydrate accordingly
queueMicrotask(() => {
this.#main_effect = this.#run(() => {
Fork.ensure();
return branch(() => this.#children(this.#anchor));
});

Expand Down
15 changes: 6 additions & 9 deletions packages/svelte/src/internal/client/reactivity/deriveds.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @import { Derived, Effect, Source } from '#client' */
/** @import { Fork } from './forks.js'; */
import { DEV } from 'esm-env';
import {
CLEAN,
Expand Down Expand Up @@ -123,14 +124,14 @@ export function async_derived(fn, location) {

var restore = capture();

var fork = active_fork;
var fork = /** @type {Fork} */ (active_fork);
var ran = boundary.ran;

if (should_suspend) {
if (!ran) {
boundary.increment();
} else {
fork?.increment();
fork.increment();
}
}

Expand All @@ -147,17 +148,13 @@ export function async_derived(fn, location) {
if (!ran) {
boundary.decrement();
} else {
fork?.decrement();
fork.decrement();
}
}

if (fork !== null) {
fork.run(() => {
internal_set(signal, v);
});
} else {
fork.run(() => {
internal_set(signal, v);
}
});

if (DEV && location !== undefined) {
recent_async_deriveds.add(signal);
Expand Down