From 4236041f7b4210c27ea6a5f40995c25e49426fea Mon Sep 17 00:00:00 2001 From: gwleuverink Date: Wed, 2 Dec 2026 00:38:54 +0100 Subject: [PATCH 01/10] Say what happens to a task that captures what cannot be sent --- resources/views/docs/mobile/4/digging-deeper/async-tasks.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md index a9f048e7..cccaa960 100644 --- a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md +++ b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md @@ -65,8 +65,9 @@ $month = $this->month; AsyncTask::dispatch(static fn () => Report::build($month)); ``` -Everything the closure captures must be serializable. Resources, PDO handles, and open file pointers can't -cross the thread boundary and will throw. +Everything the closure captures must be serializable. An open file, a database connection or a generator can't +cross the thread boundary, so a task that captures one never starts. Its `failed()` callback receives the reason +right away. Without a `failed()` callback, the reason only shows in the log. ## Handling results From 8b6f0dde6b197ef3c3dbbdd07d10985636aaf0c4 Mon Sep 17 00:00:00 2001 From: gwleuverink Date: Wed, 2 Dec 2026 00:38:54 +0100 Subject: [PATCH 02/10] Document groups of async tasks with AsyncTask::all() --- .../mobile/4/digging-deeper/async-tasks.md | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md index cccaa960..7cf57d3e 100644 --- a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md +++ b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md @@ -222,6 +222,116 @@ Each callback fires as its own task completes — there's no ordering guarantee dispatched than the pool has slots for, the extras queue up and run as slots free up. This helps to limit overall memory consumption. +If you need the results of several tasks together, you may [group them](#grouping-tasks) instead. + +## Grouping tasks + +Often a screen has nothing to show until several tasks are done. Instead of keeping count in each `finished()` +callback, you may pass your closures to `AsyncTask::all()`. It runs each closure as a task of its own, side by side, +and reports back once: + +```php +use App\Models\Order; +use App\Models\User; +use Native\Mobile\AsyncTask; +use Native\Mobile\Exceptions\AsyncTaskException; + +public function loadDashboard(): void +{ + $this->loading = true; + + AsyncTask::all([ + 'users' => static fn () => User::count(), + 'unpaid' => static fn () => Order::where('paid', false)->count(), + ]) + ->finished(function (array $counts) { + $this->counts = $counts; // ['users' => 120, 'unpaid' => 3] + $this->loading = false; + }) + ->failed(function (AsyncTaskException $e) { + $this->error = $e->getMessage(); + $this->loading = false; + }); +} +``` + +Just like `dispatch()`, `all()` returns straight away, and the tasks start at the end of the statement. When the group +is done, your screen re-renders once, however many tasks it has. + +The `finished()` callback receives the results under the keys of your array and in the order of your array, whichever +task was done first. If your array has no keys, you get a plain list. The results travel back as JSON, so the closures +should return [scalars and arrays](#handling-results), like those of a single task. + +The callbacks of a group are [scoped to the screen](#callbacks-are-scoped-to-the-screen) that started it. A group has +no `shared()` method. + + + +### Task classes in a group + +Every value you pass to `all()` must be a closure, and anything else throws an `InvalidArgumentException` before any +task starts. To run a [task class](#task-classes) as part of a group, you may call its `handle()` method in a closure: + +```php +use App\Async\BuildReport; +use App\Models\Order; +use Native\Mobile\AsyncTask; + +public function loadMonth(): void +{ + $month = $this->month; + + AsyncTask::all([ + 'report' => static fn () => app(BuildReport::class)->handle($month), + 'unpaid' => static fn () => Order::where('paid', false)->count(), + ])->finished(function (array $results) { + $this->report = $results['report']; + $this->unpaid = $results['unpaid']; + }); +} +``` + +### When a task fails + +The first task that fails settles the group. Your `failed()` callback is called once, with the `AsyncTaskException` +of that task, and `finished()` is not called. + +The tasks that have not started by then never run. A task that is already running can't be stopped, so it runs to its +end and its result is dropped. Keep this in mind when your tasks write something: a change may still be saved after +`failed()` was called. + +If the group has no `failed()` callback, its failure only leaves a line in the debug log, while `APP_DEBUG` is on. + +### Timeouts + +Each task of a group may take 60 seconds. You may choose another deadline with the `timeout()` method, or pass `0` for +no deadline at all: + +```php +AsyncTask::all([ + 'stats' => static fn () => Http::get('https://api.example.com/stats')->json(), + 'news' => static fn () => Http::get('https://api.example.com/news')->json(), +]) + ->timeout(10) + ->finished(function (array $results) { + $this->stats = $results['stats']; + $this->news = $results['news']; + }) + ->failed(function (AsyncTaskException $e) { + $this->error = $e->getMessage(); // The async task did not complete within 10 seconds. + }); +``` + +A task that passes its deadline fails the group. The deadline counts from the start of the group, so the time that a +task waits for its turn is part of it. By default, two tasks run at the same time. You may raise that to at most four +with the `NATIVEPHP_ASYNC_MAX_SLOTS` environment variable, which takes effect the next time you build your app. + ## Task classes For anything you'd rather not write inline, extend `AsyncTask` and put the work in `handle()`: From 24da967c304e398e7efb68c4535ab5b8eb71eb95 Mon Sep 17 00:00:00 2001 From: gwleuverink Date: Wed, 2 Dec 2026 00:38:54 +0100 Subject: [PATCH 03/10] Document waiting for a group of async tasks --- .../mobile/4/digging-deeper/async-tasks.md | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md index 7cf57d3e..edff4be9 100644 --- a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md +++ b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md @@ -332,6 +332,72 @@ A task that passes its deadline fails the group. The deadline counts from the st task waits for its turn is part of it. By default, two tasks run at the same time. You may raise that to at most four with the `NATIVEPHP_ASYNC_MAX_SLOTS` environment variable, which takes effect the next time you build your app. +### Waiting for the results + +Sometimes a handler needs the results before it can go on. The `wait()` method starts the group, holds your handler +until every task is done, and gives you the results under their keys: + +```php +public function refresh(): void +{ + $counts = AsyncTask::all([ + 'users' => static fn () => User::count(), + 'unpaid' => static fn () => Order::where('paid', false)->count(), + ])->wait(); + + $this->summary = "{$counts['users']} users, {$counts['unpaid']} unpaid orders"; +} +``` + +While your handler waits, your screen waits with it. It doesn't render, so a spinner that you switch on right before +`wait()` never shows. Taps and other events are kept and handled once your handler returns, and polls wait too. So +`wait()` is for short work that is done sooner side by side than one piece after another. For anything longer, you +should let `finished()` take the results. + +You may also start the group first, do some other work in your handler, and collect the results after that: + +```php +$group = AsyncTask::all([ + 'users' => static fn () => User::count(), + 'unpaid' => static fn () => Order::where('paid', false)->count(), +]); + +$group->start(); + +$this->totals = Totals::load(); + +$counts = $group->wait(); +``` + +When a task fails or passes its deadline, `wait()` throws its `AsyncTaskException`: + +```php +try { + $this->news = AsyncTask::all([ + 'local' => static fn () => Http::get('https://api.example.com/news/local')->json(), + 'world' => static fn () => Http::get('https://api.example.com/news/world')->json(), + ])->timeout(5)->wait(); +} catch (AsyncTaskException $e) { + $this->error = $e->getMessage(); +} +``` + +If the group has a `failed()` callback, that is called instead and `wait()` returns `null`. A `finished()` callback +runs before `wait()` returns. With a timeout of `0`, `wait()` has no deadline either, so a task that never ends holds +your screen for good. + +You may only wait in a native screen, such as in a handler, in `mount()`, in a `#[Poll]` method or in an `#[On]` method. +In a job, in the work of another task and in a web view, `wait()` starts no task and fails with the reason. + +A single `dispatch()` has no `wait()` method. To wait for one task, you may pass `all()` a single closure. + + + ## Task classes For anything you'd rather not write inline, extend `AsyncTask` and put the work in `handle()`: @@ -410,6 +476,7 @@ the callbacks run on your UI thread, in your component. - The work closure must be `static` and everything it captures must be serializable. - Results round-trip as JSON — return scalars and arrays; pass large data by file path or cache key. - Tasks run once, with no automatic retry. +- `wait()` holds your screen until the whole group is done, so keep it for short work. - Scoped callbacks are dropped if the user navigates away from the screen that started the work; use `shared()` when the result matters regardless of what screen the user moves to. - Async tasks don't survive the app being killed. For durable background work, use [Queues](queues). From eaf951cad35d46659cb09f97284c8c2f293b2ca1 Mon Sep 17 00:00:00 2001 From: gwleuverink Date: Wed, 2 Dec 2026 00:38:54 +0100 Subject: [PATCH 04/10] Document how the fake runs a group of async tasks --- .../mobile/4/digging-deeper/async-tasks.md | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md index edff4be9..1486245d 100644 --- a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md +++ b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md @@ -458,6 +458,34 @@ $fake->assertDispatched() Available assertions: `assertDispatched()` (optionally with a filter closure), `assertNotDispatched()`, `assertDispatchedTimes()`, and `assertShared('alias')`. +The work passes the same checks as in your app before it runs, so a closure that captures an open file is refused in +your test as well. + +A [group](#grouping-tasks) runs its tasks inline too, in the order of your array, and each of them is recorded as a +dispatch. `wait()` gives you the results at once: + +```php +use App\Models\User; +use App\NativeComponents\Dashboard; +use Native\Mobile\AsyncTask; +use Native\Mobile\Testing\Native; + +it('counts the users and the unpaid orders', function () { + $fake = AsyncTask::fake(); + + User::factory()->count(3)->create(); + + Native::test(Dashboard::class) + ->tap('Refresh') + ->assertSee('3 users, 0 unpaid orders'); + + $fake->assertDispatchedTimes(2); +}); +``` + +Under the fake, every task of a group runs, also the ones after a task that failed. Without the fake no task runs in a +test, so `wait()` fails there with a message that tells you to call `AsyncTask::fake()`. + ## How It Works When you dispatch a task, the work closure is serialized and handed to a background PHP context — a full PHP From d402920788dd19c69471e46f41b72a7c3fb07cea Mon Sep 17 00:00:00 2001 From: gwleuverink Date: Wed, 2 Dec 2026 01:44:59 +0100 Subject: [PATCH 05/10] Name the max_slots option and say how to keep a stopped wait quiet --- resources/views/docs/mobile/4/digging-deeper/async-tasks.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md index 1486245d..661ad607 100644 --- a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md +++ b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md @@ -330,7 +330,8 @@ AsyncTask::all([ A task that passes its deadline fails the group. The deadline counts from the start of the group, so the time that a task waits for its turn is part of it. By default, two tasks run at the same time. You may raise that to at most four -with the `NATIVEPHP_ASYNC_MAX_SLOTS` environment variable, which takes effect the next time you build your app. +with the `async.max_slots` option in `config/nativephp.php`, or the `NATIVEPHP_ASYNC_MAX_SLOTS` environment variable +it reads. The change takes effect the next time you build your app. ### Waiting for the results @@ -394,7 +395,8 @@ A single `dispatch()` has no `wait()` method. To wait for one task, you may pass From fa1ebd48e359987f51aa538d93e35e72ae3c58ff Mon Sep 17 00:00:00 2001 From: gwleuverink Date: Wed, 2 Dec 2026 10:51:13 +0100 Subject: [PATCH 06/10] Tighten the start of Grouping tasks and fold in task classes --- .../mobile/4/digging-deeper/async-tasks.md | 55 +++++-------------- 1 file changed, 14 insertions(+), 41 deletions(-) diff --git a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md index 661ad607..9c92fad4 100644 --- a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md +++ b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md @@ -222,17 +222,12 @@ Each callback fires as its own task completes — there's no ordering guarantee dispatched than the pool has slots for, the extras queue up and run as slots free up. This helps to limit overall memory consumption. -If you need the results of several tasks together, you may [group them](#grouping-tasks) instead. - ## Grouping tasks -Often a screen has nothing to show until several tasks are done. Instead of keeping count in each `finished()` -callback, you may pass your closures to `AsyncTask::all()`. It runs each closure as a task of its own, side by side, -and reports back once: +When a screen needs the results of several tasks together, you may pass the closures to `AsyncTask::all()`. Each +closure runs as a task of its own, and the group reports back once: ```php -use App\Models\Order; -use App\Models\User; use Native\Mobile\AsyncTask; use Native\Mobile\Exceptions\AsyncTaskException; @@ -255,48 +250,26 @@ public function loadDashboard(): void } ``` -Just like `dispatch()`, `all()` returns straight away, and the tasks start at the end of the statement. When the group -is done, your screen re-renders once, however many tasks it has. - -The `finished()` callback receives the results under the keys of your array and in the order of your array, whichever -task was done first. If your array has no keys, you get a plain list. The results travel back as JSON, so the closures -should return [scalars and arrays](#handling-results), like those of a single task. +`all()` returns straight away, and its tasks start at the end of the statement. When the whole group is done, your +screen re-renders once. `finished()` receives the results under the keys and in the order of your array, whichever task +was done first, or as a plain list if your array has no keys. As with a single task, return +[scalars and arrays](#handling-results). -The callbacks of a group are [scoped to the screen](#callbacks-are-scoped-to-the-screen) that started it. A group has +The callbacks are [scoped to the screen](#callbacks-are-scoped-to-the-screen) that started the group, and a group has no `shared()` method. +`all()` only takes closures, and anything else throws an `InvalidArgumentException` before any task starts. To run a +[task class](#task-classes) in a group, call its `handle()` method in a closure, such as +`static fn () => app(BuildReport::class)->handle($month)`. + -### Task classes in a group - -Every value you pass to `all()` must be a closure, and anything else throws an `InvalidArgumentException` before any -task starts. To run a [task class](#task-classes) as part of a group, you may call its `handle()` method in a closure: - -```php -use App\Async\BuildReport; -use App\Models\Order; -use Native\Mobile\AsyncTask; - -public function loadMonth(): void -{ - $month = $this->month; - - AsyncTask::all([ - 'report' => static fn () => app(BuildReport::class)->handle($month), - 'unpaid' => static fn () => Order::where('paid', false)->count(), - ])->finished(function (array $results) { - $this->report = $results['report']; - $this->unpaid = $results['unpaid']; - }); -} -``` - ### When a task fails The first task that fails settles the group. Your `failed()` callback is called once, with the `AsyncTaskException` From 43688080662f023a540efa1a14aa958787e02420 Mon Sep 17 00:00:00 2001 From: gwleuverink Date: Wed, 2 Dec 2026 10:51:30 +0100 Subject: [PATCH 07/10] Merge the failure and timeout parts of a group and move the slot count --- .../mobile/4/digging-deeper/async-tasks.md | 38 ++++++------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md index 9c92fad4..3a0844a6 100644 --- a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md +++ b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md @@ -222,6 +222,10 @@ Each callback fires as its own task completes — there's no ordering guarantee dispatched than the pool has slots for, the extras queue up and run as slots free up. This helps to limit overall memory consumption. +By default, two tasks run at the same time. You may raise that to at most four with the `async.max_slots` option in +`config/nativephp.php`, or the `NATIVEPHP_ASYNC_MAX_SLOTS` environment variable it reads. The change takes effect the +next time you build your app. + ## Grouping tasks When a screen needs the results of several tasks together, you may pass the closures to `AsyncTask::all()`. Each @@ -270,42 +274,24 @@ a test doesn't show this. -### When a task fails - -The first task that fails settles the group. Your `failed()` callback is called once, with the `AsyncTaskException` -of that task, and `finished()` is not called. - -The tasks that have not started by then never run. A task that is already running can't be stopped, so it runs to its -end and its result is dropped. Keep this in mind when your tasks write something: a change may still be saved after -`failed()` was called. +### Failures and timeouts -If the group has no `failed()` callback, its failure only leaves a line in the debug log, while `APP_DEBUG` is on. +The first task that fails settles the group: `failed()` is called once with its `AsyncTaskException`, and `finished()` +is not called. Tasks that have not started by then never run. A task that is already running can't be stopped, so it +runs to its end and its result is dropped, and a change it writes may still be saved after `failed()` was called. +Without a `failed()` callback, the failure only leaves a line in the debug log, while `APP_DEBUG` is on. -### Timeouts - -Each task of a group may take 60 seconds. You may choose another deadline with the `timeout()` method, or pass `0` for -no deadline at all: +Each task may take 60 seconds. You may set another deadline in seconds with `timeout()`, or `0` for none. A task that +passes its deadline fails the group, and the time it waits for a free slot counts toward it: ```php -AsyncTask::all([ - 'stats' => static fn () => Http::get('https://api.example.com/stats')->json(), - 'news' => static fn () => Http::get('https://api.example.com/news')->json(), -]) +AsyncTask::all($requests) ->timeout(10) - ->finished(function (array $results) { - $this->stats = $results['stats']; - $this->news = $results['news']; - }) ->failed(function (AsyncTaskException $e) { $this->error = $e->getMessage(); // The async task did not complete within 10 seconds. }); ``` -A task that passes its deadline fails the group. The deadline counts from the start of the group, so the time that a -task waits for its turn is part of it. By default, two tasks run at the same time. You may raise that to at most four -with the `async.max_slots` option in `config/nativephp.php`, or the `NATIVEPHP_ASYNC_MAX_SLOTS` environment variable -it reads. The change takes effect the next time you build your app. - ### Waiting for the results Sometimes a handler needs the results before it can go on. The `wait()` method starts the group, holds your handler From fee92338ccc0be676921c63ea3c05500346e3651 Mon Sep 17 00:00:00 2001 From: gwleuverink Date: Wed, 2 Dec 2026 10:51:45 +0100 Subject: [PATCH 08/10] Tighten Waiting for the results --- .../mobile/4/digging-deeper/async-tasks.md | 48 ++++++------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md index 3a0844a6..c2f1ccad 100644 --- a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md +++ b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md @@ -294,8 +294,8 @@ AsyncTask::all($requests) ### Waiting for the results -Sometimes a handler needs the results before it can go on. The `wait()` method starts the group, holds your handler -until every task is done, and gives you the results under their keys: +When a handler can't go on without the results, you may call `wait()`. It starts the group, holds your handler until +every task is done, and returns the results under their keys: ```php public function refresh(): void @@ -309,53 +309,33 @@ public function refresh(): void } ``` -While your handler waits, your screen waits with it. It doesn't render, so a spinner that you switch on right before -`wait()` never shows. Taps and other events are kept and handled once your handler returns, and polls wait too. So -`wait()` is for short work that is done sooner side by side than one piece after another. For anything longer, you -should let `finished()` take the results. - -You may also start the group first, do some other work in your handler, and collect the results after that: - -```php -$group = AsyncTask::all([ - 'users' => static fn () => User::count(), - 'unpaid' => static fn () => Order::where('paid', false)->count(), -]); - -$group->start(); - -$this->totals = Totals::load(); - -$counts = $group->wait(); -``` +While your handler waits, your screen doesn't render, so a spinner that you switch on right before `wait()` never +shows. Taps, other events and polls wait until your handler returns. Keep `wait()` for short work that is done sooner +side by side than one piece after another, and let `finished()` take the results of anything longer. You may also +`start()` the group first, do other work in your handler, and call `wait()` after that. When a task fails or passes its deadline, `wait()` throws its `AsyncTaskException`: ```php try { - $this->news = AsyncTask::all([ - 'local' => static fn () => Http::get('https://api.example.com/news/local')->json(), - 'world' => static fn () => Http::get('https://api.example.com/news/world')->json(), - ])->timeout(5)->wait(); + $this->news = AsyncTask::all($requests)->timeout(5)->wait(); } catch (AsyncTaskException $e) { $this->error = $e->getMessage(); } ``` If the group has a `failed()` callback, that is called instead and `wait()` returns `null`. A `finished()` callback -runs before `wait()` returns. With a timeout of `0`, `wait()` has no deadline either, so a task that never ends holds -your screen for good. - -You may only wait in a native screen, such as in a handler, in `mount()`, in a `#[Poll]` method or in an `#[On]` method. -In a job, in the work of another task and in a web view, `wait()` starts no task and fails with the reason. +runs before `wait()` returns. With `timeout(0)`, a task that never ends holds your screen for good. -A single `dispatch()` has no `wait()` method. To wait for one task, you may pass `all()` a single closure. +You may only wait in a native screen, such as in a handler, in `mount()`, or in a `#[Poll]` or `#[On]` method. In a +job, in the work of another task and in a web view, `wait()` starts no task and fails with the reason. A single +`dispatch()` has no `wait()` method, so to wait for one task, pass `all()` a single closure. From 8afd1f87fd703c7b99d1161227ba3f2483f37f21 Mon Sep 17 00:00:00 2001 From: gwleuverink Date: Wed, 2 Dec 2026 10:51:53 +0100 Subject: [PATCH 09/10] Say how the fake runs a group without a second test example --- .../mobile/4/digging-deeper/async-tasks.md | 27 +++---------------- 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md index c2f1ccad..babd18cf 100644 --- a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md +++ b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md @@ -402,30 +402,9 @@ Available assertions: `assertDispatched()` (optionally with a filter closure), ` The work passes the same checks as in your app before it runs, so a closure that captures an open file is refused in your test as well. -A [group](#grouping-tasks) runs its tasks inline too, in the order of your array, and each of them is recorded as a -dispatch. `wait()` gives you the results at once: - -```php -use App\Models\User; -use App\NativeComponents\Dashboard; -use Native\Mobile\AsyncTask; -use Native\Mobile\Testing\Native; - -it('counts the users and the unpaid orders', function () { - $fake = AsyncTask::fake(); - - User::factory()->count(3)->create(); - - Native::test(Dashboard::class) - ->tap('Refresh') - ->assertSee('3 users, 0 unpaid orders'); - - $fake->assertDispatchedTimes(2); -}); -``` - -Under the fake, every task of a group runs, also the ones after a task that failed. Without the fake no task runs in a -test, so `wait()` fails there with a message that tells you to call `AsyncTask::fake()`. +A [group](#grouping-tasks) runs its tasks inline too, in the order of your array, each recorded as a dispatch, and +`wait()` returns the results at once. Every task runs, also the ones after a task that failed. Without the fake no task +runs in a test, so `wait()` fails there with a message that tells you to call `AsyncTask::fake()`. ## How It Works From a4893dbfa051a68e6b01a4a1f3c273bdba95c583 Mon Sep 17 00:00:00 2001 From: gwleuverink Date: Wed, 2 Dec 2026 10:52:08 +0100 Subject: [PATCH 10/10] Split a long sentence on a failed group --- resources/views/docs/mobile/4/digging-deeper/async-tasks.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md index babd18cf..3dff0bd1 100644 --- a/resources/views/docs/mobile/4/digging-deeper/async-tasks.md +++ b/resources/views/docs/mobile/4/digging-deeper/async-tasks.md @@ -278,8 +278,8 @@ a test doesn't show this. The first task that fails settles the group: `failed()` is called once with its `AsyncTaskException`, and `finished()` is not called. Tasks that have not started by then never run. A task that is already running can't be stopped, so it -runs to its end and its result is dropped, and a change it writes may still be saved after `failed()` was called. -Without a `failed()` callback, the failure only leaves a line in the debug log, while `APP_DEBUG` is on. +runs to its end and its result is dropped. A change it writes may still be saved after `failed()` was called. Without +a `failed()` callback, the failure only leaves a line in the debug log, while `APP_DEBUG` is on. Each task may take 60 seconds. You may set another deadline in seconds with `timeout()`, or `0` for none. A task that passes its deadline fails the group, and the time it waits for a free slot counts toward it: