mirror of
https://github.com/simstudioai/sim.git
synced 2026-11-02 22:52:17 +08:00
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. Confirmed from a crashed run's spans: the dispatch log line carries backend: "direct", and no knowledge-process-document runs exist for that knowledge base while other knowledge bases dispatched normally in the same window. On the largest connector — 7,730 documents, individual XLSX files over 20MB — that exhausts the heap and OOMs the sync. Inside a run the answer is unconditionally yes: the platform is what is executing the process, so no environment guess can beat the run marker. Two independent signals, because this has now been got wrong twice — the SDK's ambient taskContext.isInsideTask, already load-bearing in getAsyncBackendType for the same carve-out, and a marker written by the global init lifecycle hook, which uses only the documented public surface. Neither reads TRIGGER_SECRET_KEY or TRIGGER_DEV_ENABLED. Resolving true inside a run is safe under either hypothesis about which conjunct was false: if a run process lacks the secret key the SDK rejects the batch trigger and dispatch falls back in-process, which is where a false predicate lands today. The first evaluation per process now logs the resolved inputs, naming which conjunct is false. A predicate unit test would not have caught either shipment; both were deploy-environment differences only observable from inside a worker.