Skip to content

Commit e1ca02e

Browse files
committed
fix(sdk): drop triggerAndSubscribe from TriggerClient surface
`triggerAndSubscribe_internal` requires `taskContext.ctx` and uses `ctx.run.id` as the parent run id, so it is fundamentally an inside-task primitive. Including it on the curated `tasksApi` was a mistake — with the default `inheritContext: false`, the scoped taskContext is masked to undefined and the method always throws "triggerAndSubscribe can only be used from inside a task.run()". Type test updated to assert the method is no longer reachable from the instance surface.
1 parent 8a8fb97 commit e1ca02e

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

packages/trigger-sdk/src/v3/triggerClient.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,14 @@ import * as promptsModule from "./prompts.js";
1414
import * as queuesModule from "./queues.js";
1515
import { runs } from "./runs.js";
1616
import * as schedulesModule from "./schedules/index.js";
17-
import {
18-
batchTrigger,
19-
trigger,
20-
triggerAndSubscribe,
21-
} from "./shared.js";
17+
import { batchTrigger, trigger } from "./shared.js";
2218

2319
export type TriggerClientConfig = ApiClientConfiguration & {
2420
/** Inherit ambient task context (parentRunId, lockToVersion, isTest) when called from inside a task. Default `false`. */
2521
inheritContext?: boolean;
2622
};
2723

28-
const tasksApi = { trigger, batchTrigger, triggerAndSubscribe };
24+
const tasksApi = { trigger, batchTrigger };
2925
const batchInstanceKeys = ["trigger", "triggerByTask", "retrieve"] as const;
3026
const schedulesInstanceKeys = [
3127
"activate",

packages/trigger-sdk/src/v3/triggerClient.types.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ describe("TriggerClient surface — type-level guarantees", () => {
4646
describe("TriggerClient surface — curated subsets", () => {
4747
it("instance.tasks drops inside-task-only and definition-time helpers", () => {
4848
type Keys = keyof typeof client.tasks;
49-
expectTypeOf<Keys>().toEqualTypeOf<"trigger" | "batchTrigger" | "triggerAndSubscribe">();
49+
expectTypeOf<Keys>().toEqualTypeOf<"trigger" | "batchTrigger">();
5050
// @ts-expect-error — triggerAndWait is not on the instance surface.
5151
client.tasks.triggerAndWait;
5252
// @ts-expect-error — batchTriggerAndWait is not on the instance surface.
5353
client.tasks.batchTriggerAndWait;
54+
// @ts-expect-error — triggerAndSubscribe requires a task context; not on the instance surface.
55+
client.tasks.triggerAndSubscribe;
5456
// @ts-expect-error — hooks like onStart are task-definition-time, not on the client.
5557
client.tasks.onStart;
5658
});

0 commit comments

Comments
 (0)