MCPcopy
hub / github.com/triggerdotdev/trigger.dev / waitForEvent

Method waitForEvent

packages/trigger-sdk/src/io.ts:373–437  ·  view source on GitHub ↗
(
    cacheKey: string | any[],
    event: {
      name: string;
      schema?: T;
      filter?: EventFilter;
      source?: string;
      contextFilter?: EventFilter;
      accountId?: string;
    },
    options?: { timeoutInSeconds?: number }
  )

Source from the content-addressed store, hash-verified

371 }
372
373 async waitForEvent<T extends z.ZodTypeAny = z.ZodTypeAny>(
374 cacheKey: string | any[],
375 event: {
376 name: string;
377 schema?: T;
378 filter?: EventFilter;
379 source?: string;
380 contextFilter?: EventFilter;
381 accountId?: string;
382 },
383 options?: { timeoutInSeconds?: number }
384 ): Promise<WaitForEventResult<z.output<T>>> {
385 const timeoutInSeconds = options?.timeoutInSeconds ?? 60 * 60;
386
387 return (await this.runTask(
388 cacheKey,
389 async (task, io) => {
390 if (!task.callbackUrl) {
391 throw new Error("No callbackUrl found on task");
392 }
393
394 await this.triggerClient.createEphemeralEventDispatcher({
395 url: task.callbackUrl,
396 name: event.name,
397 filter: event.filter,
398 contextFilter: event.contextFilter,
399 source: event.source,
400 accountId: event.accountId,
401 timeoutInSeconds,
402 });
403
404 return {} as Promise<{}>;
405 },
406 {
407 name: "Wait for Event",
408 icon: "custom-event",
409 params: {
410 name: event.name,
411 source: event.source,
412 filter: event.filter,
413 contextFilter: event.contextFilter,
414 accountId: event.accountId,
415 },
416 callback: {
417 enabled: true,
418 timeoutInSeconds,
419 },
420 properties: [
421 {
422 label: "Event",
423 text: event.name,
424 },
425 {
426 label: "Timeout",
427 text: `${timeoutInSeconds}s`,
428 },
429 ...(event.source ? [{ label: "Source", text: event.source }] : []),
430 ...(event.accountId ? [{ label: "Account ID", text: event.accountId }] : []),

Callers 1

built-ins.tsFile · 0.80

Calls 4

runTaskMethod · 0.95
waitForEventSchemaFunction · 0.90
parseMethod · 0.80

Tested by

no test coverage detected