Skip to content

Commit c008320

Browse files
committed
Correct tasks usage in documentation
The 'tasks as package' section in the documentation had an incorrect example under 'Use tasks in your apps' which needed correction to align with the actual package usage. - Fixed incorrect import of tasks by updating to the correct import from '@repo/tasks/trigger'. - Updated the syntax to use 'tasks.trigger' with type parameters, following the new pattern established for triggering tasks with TypeScript. - Added error handling to catch and log errors during task execution, returning a meaningful error message instead of just failing silently. This update ensures developers have an accurate reference when implementing tasks in their applications, especially given the breaking changes in TypeScript compatibility due to recent package updates.
1 parent 0ee9448 commit c008320

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

docs/manual-setup.mdx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -472,14 +472,21 @@ export const helloWorld = task({
472472
```typescript
473473
"use server";
474474

475-
import { helloWorld } from "@repo/tasks";
475+
import { tasks } from "@repo/tasks/trigger";
476+
import type { helloWorld } from "@repo/tasks";
477+
// 👆 type only import
476478

477479
export async function triggerHelloWorld(name: string) {
478-
const handle = await helloWorld.trigger({
479-
name: name,
480-
});
481-
482-
return { runId: handle.id };
480+
try {
481+
const handle = await tasks.trigger<typeof helloWorld>("hello-world", {
482+
name: name,
483+
});
484+
485+
return handle.id;
486+
} catch (error) {
487+
console.error(error);
488+
return { error: "something went wrong" };
489+
}
483490
}
484491
```
485492

0 commit comments

Comments
 (0)