René's URL Explorer Experiment


Title: fix(knowledge): dispatch document processing from inside Trigger.dev runs by waleedlatif1 · Pull Request #6920 · simstudioai/sim · GitHub

Open Graph Title: fix(knowledge): dispatch document processing from inside Trigger.dev runs by waleedlatif1 · Pull Request #6920 · simstudioai/sim

X Title: fix(knowledge): dispatch document processing from inside Trigger.dev runs by waleedlatif1 · Pull Request #6920 · simstudioai/sim

Description: This is the fix for the knowledge-connector-sync OOMs. isTriggerAvailable() returns false inside Trigger.dev worker runs, so every connector document has been downloaded, parsed, chunked, and embedded inside the sync task at concurrency 5 rather than dispatched to knowledge-process-document. The per-document fan-out is inert in production and has been for some time. Evidence From the crashed run's spans, not inference: The dispatch log line carries backend: "direct" — the literal branch discriminator in processDocumentsWithQueue. dispatchViaBatchTrigger was never entered. Zero knowledge-process-document runs exist for that knowledge base in the window, while five other knowledge bases dispatched normally in the same period. No Failed to batchTrigger, no Trigger.dev batches dispatched, no in-process fallback warning — and other logger.error lines do render in that trace, so the absence is meaningful rather than a gap. On the largest connector — 7,730 documents, individual XLSX files over 20MB (one span shows a 21,099,055-byte buffer, 12 sheets, 65,821 rows) — that exhausts the heap. Smaller connectors do the same in-process work and simply never reach the ceiling, which is why only one connector crashes. Why the previous fix didn't take 04e0fe00c0 (#6869) added syncEnvVars setting TRIGGER_DEV_ENABLED: 'TRUE' for exactly this bug. That commit is in v0.8.7; the crashed run executed on the v0.8.7 deploy. The flag was still effectively false a day later. Its TSDoc also asserts that TRIGGER_SECRET_KEY is something "only the Trigger.dev runtime provides". The SDK's own resolution path (APIClientManagerAPI.accessToken) reads it from the environment with no in-run bypass — if runs lacked it, triggering a child task from inside a task would be impossible, and Trigger.dev documents that as a first-class pattern. So that comment is corrected here. The fix Inside a run the answer is unconditionally yes: the platform is what is executing the process, so no environment guess can be more reliable than the run marker itself. Two independent signals, because this has now been got wrong twice and either alone is a single point of failure: taskContext.isInsideTask — the SDK's ambient flag, already load-bearing in getAsyncBackendType for precisely this carve-out. Its existing comment describes the same bug class: "a worker pod missing TRIGGER_DEV_ENABLED=true silently routes cell jobs to the database backend that nothing's draining." isTriggerAvailable() never got the same treatment. A marker written by the global init lifecycle hook, which uses only the documented public surface and so holds even if the internal taskContext shape moves. It lives on globalThis under a registered symbol rather than in module scope, because the build bundles the config entrypoint alongside the task graph and a duplicated module binding would let the hook write one copy while dispatch reads another. Neither signal reads TRIGGER_SECRET_KEY or TRIGGER_DEV_ENABLED. Non-regressive under either hypothesis about which conjunct was false. If a run process turns out not to expose the secret key, the SDK rejects the batch trigger and dispatchViaBatchTrigger falls back to in-process — which is exactly where a false predicate lands today. Regression guard The first evaluation per process logs the resolved inputs — available, insideTriggerRun, triggerDevEnabled, hasSecretKey. Once per worker process, not per dispatch. A predicate unit test would not have caught either shipment; both were deploy-environment differences. A startup assertion would now be tautological (the init hook makes the predicate true by construction), and a health check tests the app container, which was never broken — the failure is an app-vs-worker asymmetry, visible only from inside a worker. This log names which conjunct is false, which is the question the investigation could not answer from code alone. Blast radius isTriggerAvailable() has three call sites; only processDocumentsWithQueue is reachable inside a run, and it is this incident. dispatchSync and dispatchCleanupJobs are cron-only and unaffected. Noted for follow-up, not touched here: several sites using the plain isTriggerDevEnabled flag do execute inside runs with the same silent-inline failure mode — lib/table/backfill-runner.ts, lib/table/workflow-columns.ts, lib/execution/remote-sandbox/image-registry.ts. And lib/messaging/lifecycle.ts duplicates the same conjunction where the false arm silently drops the email (app-only today, but the same latent bug copy-pasted). Verification type-check clean · check:audits 32/32 · 2,059 tests across lib/knowledge, lib/core, and background. Mutation-checked: disabling the run-marker disjunct turns both "inside a run" dispatch tests red; dropping the init marker turns 4 red; dropping taskContext turns 1 red. No test that cannot fail. Known untested: the init: wiring in trigger.config.ts cannot be unit-tested here, since config hooks are invoked by the Trigger.dev runtime. That is precisely why the fix does not rely on it alone. Follow-up dispatchViaBatchTrigger's per-chunk fallback-on-failure is deliberately untouched — it is the safety net that makes this change non-regressive. Removing it before this lands would delete the only in-process path that isn't firing while leaving the one that is. Dispatch granularity (SYNC_BATCH_SIZE = 5 producing one batchTrigger call per five documents) is a real design smell, but no batchTrigger call has ever been made from a sync worker, so no Trigger.dev limit has been approached. That becomes measurable only after this lands.

Open Graph Description: This is the fix for the knowledge-connector-sync OOMs. isTriggerAvailable() returns false inside Trigger.dev worker runs, so every connector document has been downloaded, parsed, chunked, and embed...

X Description: This is the fix for the knowledge-connector-sync OOMs. isTriggerAvailable() returns false inside Trigger.dev worker runs, so every connector document has been downloaded, parsed, chunked, and embed...

Opengraph URL: https://github.com/simstudioai/sim/pull/6920

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:92258b15-5257-f11b-720b-0e0cdf3a00e5
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD248:9CA74:DEC7B2:131D0E8:6AFB5F0B
html-safe-noncefad1264f53aa67c316f2508c25ca7563f86de1b72c74874de55492e56316ccbb
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjQ4OjlDQTc0OkRFQzdCMjoxMzFEMEU4OjZBRkI1RjBCIiwidmlzaXRvcl9pZCI6Ijc1MTI1MzY3NjQ3ODM0ODQ2ODMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacb973f694f820076ab99cdd9b1bdaa91cf7b15b457d45b25d5913b55ed56c8f9e
hovercard-subject-tagpull_request:4327751575
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/6920/files
twitter:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
og:image:altThis is the fix for the knowledge-connector-sync OOMs. isTriggerAvailable() returns false inside Trigger.dev worker runs, so every connector document has been downloaded, parsed, chunked, and embed...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneea33d13c96d0ff66bd8fa906b193d2213536b78cb06b0c50a4632c58b1418f94
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/simstudioai/sim git https://github.com/simstudioai/sim.git
octolytics-dimension-user_id199344406
octolytics-dimension-user_loginsimstudioai
octolytics-dimension-repository_id912559512
octolytics-dimension-repository_nwosimstudioai/sim
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id912559512
octolytics-dimension-repository_network_root_nwosimstudioai/sim
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release59ef97164c52cf59bd10558ddec9c4f482763988
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/simstudioai/sim/pull/6920/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F6920%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F6920%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=simstudioai%2Fsim
Reloadhttps://github.com/simstudioai/sim/pull/6920/files
Reloadhttps://github.com/simstudioai/sim/pull/6920/files
Reloadhttps://github.com/simstudioai/sim/pull/6920/files
simstudioaihttps://github.com/simstudioai
simhttps://github.com/simstudioai/sim
Codehttps://github.com/simstudioai/sim
Issues129 (129)https://github.com/simstudioai/sim/issues
Pull requests197 (197)https://github.com/simstudioai/sim/pulls
Actionshttps://github.com/simstudioai/sim/actions
Projectshttps://github.com/simstudioai/sim/projects
Security and qualityhttps://github.com/simstudioai/sim/security
Insightshttps://github.com/simstudioai/sim/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
waleedlatif1https://github.com/waleedlatif1
staginghttps://github.com/simstudioai/sim/tree/staging
fix/sync-dispatchhttps://github.com/simstudioai/sim/tree/fix/sync-dispatch
Conversation 3 https://github.com/simstudioai/sim/pull/6920
Commits 1 https://github.com/simstudioai/sim/pull/6920/commits
Checks 30 https://github.com/simstudioai/sim/pull/6920/checks
Files changed https://github.com/simstudioai/sim/pull/6920/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6920/files
fix(knowledge): dispatch document processing from inside Trigger.dev runs https://github.com/simstudioai/sim/pull/6920/files#top
Show all changes 1 commit https://github.com/simstudioai/sim/pull/6920/files
5c6c078 fix(knowledge): dispatch document processing from inside Trigger.dev … waleedlatif1 Aug 21, 2026 https://github.com/simstudioai/sim/pull/6920/commits/5c6c0786c2d730db45bbb9f4f71a292e26159880
Clear filters https://github.com/simstudioai/sim/pull/6920/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6920/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6920/files
trigger-runtime.test.ts https://github.com/simstudioai/sim/pull/6920/files#diff-754b7671a85c60e62d25f5c4ba01059916fdae8a642aee6ba234250d888a6e59
trigger-runtime.ts https://github.com/simstudioai/sim/pull/6920/files#diff-d777dbf21b2f7ce08eb0d8229b0257d5aee076d31205a11120c5af187257939e
processing-queue.test.ts https://github.com/simstudioai/sim/pull/6920/files#diff-61f9b64ff566f2114b69c46afe5ee47845d13fc0758de1de3797e5322c2b1fad
service.ts https://github.com/simstudioai/sim/pull/6920/files#diff-12adff6ec055d413ec20f1debed4ca207b994d23df6de9aa4ef79bf47f2857b2
trigger.config.ts https://github.com/simstudioai/sim/pull/6920/files#diff-3e89ed60c3946e67cfc357495159a4bf5e261ea848b2fa28ddb351aa9e7a877c
apps/sim/lib/core/config/trigger-runtime.test.tshttps://github.com/simstudioai/sim/pull/6920/files#diff-754b7671a85c60e62d25f5c4ba01059916fdae8a642aee6ba234250d888a6e59
View file https://github.com/simstudioai/sim/blob/5c6c0786c2d730db45bbb9f4f71a292e26159880/apps/sim/lib/core/config/trigger-runtime.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6920/{{ revealButtonHref }}
apps/sim/lib/core/config/trigger-runtime.tshttps://github.com/simstudioai/sim/pull/6920/files#diff-d777dbf21b2f7ce08eb0d8229b0257d5aee076d31205a11120c5af187257939e
View file https://github.com/simstudioai/sim/blob/5c6c0786c2d730db45bbb9f4f71a292e26159880/apps/sim/lib/core/config/trigger-runtime.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6920/{{ revealButtonHref }}
apps/sim/lib/knowledge/documents/processing-queue.test.tshttps://github.com/simstudioai/sim/pull/6920/files#diff-61f9b64ff566f2114b69c46afe5ee47845d13fc0758de1de3797e5322c2b1fad
View file https://github.com/simstudioai/sim/blob/5c6c0786c2d730db45bbb9f4f71a292e26159880/apps/sim/lib/knowledge/documents/processing-queue.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6920/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6920/files#diff-61f9b64ff566f2114b69c46afe5ee47845d13fc0758de1de3797e5322c2b1fad
https://github.com/simstudioai/sim/pull/6920/files#diff-61f9b64ff566f2114b69c46afe5ee47845d13fc0758de1de3797e5322c2b1fad
https://github.com/simstudioai/sim/pull/6920/files#diff-61f9b64ff566f2114b69c46afe5ee47845d13fc0758de1de3797e5322c2b1fad
apps/sim/lib/knowledge/documents/service.tshttps://github.com/simstudioai/sim/pull/6920/files#diff-12adff6ec055d413ec20f1debed4ca207b994d23df6de9aa4ef79bf47f2857b2
View file https://github.com/simstudioai/sim/blob/5c6c0786c2d730db45bbb9f4f71a292e26159880/apps/sim/lib/knowledge/documents/service.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6920/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6920/files#diff-12adff6ec055d413ec20f1debed4ca207b994d23df6de9aa4ef79bf47f2857b2
https://github.com/simstudioai/sim/pull/6920/files#diff-12adff6ec055d413ec20f1debed4ca207b994d23df6de9aa4ef79bf47f2857b2
https://github.com/simstudioai/sim/pull/6920/files#diff-12adff6ec055d413ec20f1debed4ca207b994d23df6de9aa4ef79bf47f2857b2
https://github.com/simstudioai/sim/pull/6920/files#diff-12adff6ec055d413ec20f1debed4ca207b994d23df6de9aa4ef79bf47f2857b2
apps/sim/trigger.config.tshttps://github.com/simstudioai/sim/pull/6920/files#diff-3e89ed60c3946e67cfc357495159a4bf5e261ea848b2fa28ddb351aa9e7a877c
View file https://github.com/simstudioai/sim/blob/5c6c0786c2d730db45bbb9f4f71a292e26159880/apps/sim/trigger.config.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6920/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6920/files#diff-3e89ed60c3946e67cfc357495159a4bf5e261ea848b2fa28ddb351aa9e7a877c
https://github.com/simstudioai/sim/pull/6920/files#diff-3e89ed60c3946e67cfc357495159a4bf5e261ea848b2fa28ddb351aa9e7a877c
https://github.com/simstudioai/sim/pull/6920/files#diff-3e89ed60c3946e67cfc357495159a4bf5e261ea848b2fa28ddb351aa9e7a877c
https://github.com/simstudioai/sim/pull/6920/files#diff-3e89ed60c3946e67cfc357495159a4bf5e261ea848b2fa28ddb351aa9e7a877c
https://github.com/simstudioai/sim/pull/6920/files#diff-3e89ed60c3946e67cfc357495159a4bf5e261ea848b2fa28ddb351aa9e7a877c
Please reload this pagehttps://github.com/simstudioai/sim/pull/6920/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.