Skip to content

Commit 7ed1ead

Browse files
committed
refactor(trigger): tighten the comments on the worker dispatch fix
1 parent 3868baa commit 7ed1ead

2 files changed

Lines changed: 8 additions & 16 deletions

File tree

apps/sim/lib/knowledge/documents/service.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -756,11 +756,9 @@ async function dispatchViaBatchTrigger(
756756
}
757757

758758
/**
759-
* Only a total dispatch failure raises, so a chunk that failed on its own used
760-
* to leave its documents sitting at `pending` with nothing recording why —
761-
* invisible until the stuck-document sweep happened to pick them up, and never
762-
* if they aged out of its window first. Running them here costs the caller time
763-
* it hoped to hand to the queue, which is the point: the work still happens.
759+
* Only a total dispatch failure raises, so a chunk failing alone would leave its
760+
* documents at `pending` with nothing recording why. Processing them here is
761+
* slower than the queue but does not drop the work.
764762
*/
765763
if (undispatched.length > 0) {
766764
logger.warn(

apps/sim/trigger.config.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,11 @@ export default defineConfig({
7676
syncEnvVars(() => [
7777
{ name: 'DB_APP_NAME', value: 'sim-trigger' },
7878
/**
79-
* Workers run Trigger.dev by definition, but the flag that says so is
80-
* read from the environment and was only ever set on the app container.
81-
* `isTriggerAvailable()` therefore returned false inside every worker, so
82-
* anything a task dispatched — document processing above all — silently
83-
* took the in-process path instead of the queue it was written for. A
84-
* connector sync ended up chunking and embedding thousands of documents
85-
* itself, five at a time, and running until it hit its max duration.
86-
*
87-
* Safe to assert here because the check also requires TRIGGER_SECRET_KEY,
88-
* which only the Trigger.dev runtime provides: where dispatching is not
89-
* actually possible this stays false and nothing changes.
79+
* Workers run Trigger.dev by definition, but the flag saying so was only
80+
* set on the app container, so `isTriggerAvailable()` was false in every
81+
* task run and dispatched work silently took the in-process fallback.
82+
* Ineffective where dispatching is impossible: the check also requires
83+
* TRIGGER_SECRET_KEY, which only the Trigger.dev runtime provides.
9084
*/
9185
{ name: 'TRIGGER_DEV_ENABLED', value: 'TRUE' },
9286
]),

0 commit comments

Comments
 (0)