Repository navigation
docs: add Apify Actor run example task page - #5021
Jakub-Vacek wants to merge 7 commits into
Conversation
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📜 Recent review details
WalkthroughThe documentation adds an Apify Actor run guide and links it from the example-task navigation and introduction. The guide covers shared client setup, a short-run task that waits for results, and a long-run task that resumes through a webhook. It also includes dashboard testing instructions and notes about cancellation, retries, and task-output limits. Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to
|
|
|
||
| logger.info("Actor run finished", { runId: run.id, itemCount: items.length }); | ||
|
|
||
| return { runId: run.id, datasetId: run.defaultDatasetId, items }; |
There was a problem hiding this comment.
🟡 Large crawl results exceed task output limit
When a crawl returns over 10MB, apifyActorRun returns the items as task output. Trigger.dev rejects that output, so a successful Actor run ends in task failure; the webhook task has the same issue.
Learn more
Both example tasks fetch dataset items and return them as one task result. Trigger.dev documents a 10MB task-output limit in task output limits. The webhook variant also returns the complete item array at apifyLongActorRun. An Actor can produce large text or structured records even with a 1,000-item cap, so the item count does not bound the serialized output size.
Example: A crawl returns 1,000 items averaging 12KB each. Apify reports success, but returning roughly 12MB as a task result exceeds the Trigger.dev output limit.
Recommended fix: In both examples, return the dataset ID and run ID rather than the entire dataset, or explicitly limit and measure the returned data and explain how to fetch larger results separately.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
added a note about the 10MB output limit and how to read large datasets
|
|
||
| Add `apify-client` to [`external`](/config/config-file#external) in your `trigger.config.ts` file. When it's bundled, `apify-client` fails on its first API call with `TypeError: ProxyAgent is not a constructor`. | ||
|
|
||
| ```ts trigger.config.ts |
There was a problem hiding this comment.
🟡 TypeScript examples violate required fence tags
All four TypeScript examples use ts fences instead of the required typescript tag in documentation rules.
Learn more
The documentation rules require typescript for TypeScript code fences. Four fences in this page use ts, so fixing only the anchored fence leaves three violations.
Example: The config, shared client, synchronous task, and webhook task all open their code fences with ts.
Recommended fix: Change each of the four opening fences to typescript, keeping the file labels unchanged.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
keeping ts, because the site uses ts almost everywhere
| throw new Error(`Actor run ${run.id} finished with status ${run.status}`); | ||
| } | ||
|
|
||
| const { items } = await apify.dataset(run.defaultDatasetId).listItems(); |
There was a problem hiding this comment.
There was a problem hiding this comment.
listItems() without limit returns all items, and maxItems: 1000 bounds the dataset, so one call is complete
|
|
||
| - The webhook covers all four ways an Actor run can end, so a failed, aborted or timed-out Actor resumes your run with an error instead of leaving it waiting until the token times out. | ||
| - `payloadTemplate` sends only `eventType` and `resource` (the Actor run). Whatever Apify posts to `token.url` becomes the token's result, so the `ApifyWebhookPayload` type matches this template, not Apify's default webhook payload. | ||
| - The token `timeout` is longer than the Actor's `timeout`, so the Actor always finishes, and the webhook fires, before the token expires. |
There was a problem hiding this comment.
Apify sends the webhook as soon as the run ends, so a 10-minute delay is unlikely. If it happens, the task retries, which the retry-safety note covers.
Pre-agreed with the Trigger.dev team on Discord: https://discord.com/channels/1066956501299777596/1534928934184157205
✅ Checklist
Testing
Both task samples were run against a live Apify account (only
APIFY_TOKENset) on Trigger.dev Cloud, dev environment, SDK 4.7.3,apify-client2.25.0:apify-actor-run): run completes and returns the dataset items from Website Content Crawler.apify-long-actor-run): the run pauses onwait.forToken()while the Actor works (about 2 s of compute out of about 21 s total), resumes on the Apify webhook and returns the dataset items.AbortTaskRunErrorand does not retry.apify-clientbundling: withoutbuild.external: ["apify-client"], the first API call fails withTypeError: ProxyAgent is not a constructor. With it, both examples work. The page documents this.Docs:
npx mintlify broken-linksindocs/: no broken links found.npm run devindocs/) and checked the new page, the sidebar entry under "Example tasks", the row in the example tasks table and the in-page links.Changelog
Added an example task page,
docs/guides/examples/apify-actor-run.mdx, showing two ways to run an Apify Actor from a task:The page imports the shared web scraping warning, and is linked from the example tasks table in
docs/guides/introduction.mdxand the "Example tasks" group indocs/docs.json.Screenshots
💯