diff --git a/.changeset/young-spies-repeat.md b/.changeset/young-spies-repeat.md new file mode 100644 index 000000000..4e9ab90a2 --- /dev/null +++ b/.changeset/young-spies-repeat.md @@ -0,0 +1,5 @@ +--- +"inngest": patch +--- + +Allow access to userland promises when executing for `@inngest/test` diff --git a/packages/inngest/src/components/InngestStepTools.ts b/packages/inngest/src/components/InngestStepTools.ts index d74bd765c..a956ce9f0 100644 --- a/packages/inngest/src/components/InngestStepTools.ts +++ b/packages/inngest/src/components/InngestStepTools.ts @@ -39,6 +39,11 @@ export interface FoundStep extends HashedOp { fulfilled: boolean; handled: boolean; + /** + * The promise that has been returned to userland code for this step. + */ + promise: Promise; + /** * Returns a boolean representing whether or not the step was handled on this * invocation. diff --git a/packages/inngest/src/components/execution/InngestExecution.ts b/packages/inngest/src/components/execution/InngestExecution.ts index 0a45c542f..7292e624d 100644 --- a/packages/inngest/src/components/execution/InngestExecution.ts +++ b/packages/inngest/src/components/execution/InngestExecution.ts @@ -43,6 +43,11 @@ export interface MemoizedOp extends IncomingOp { */ rawArgs?: unknown[]; fulfilled?: boolean; + + /** + * The promise that has been returned to userland code. + */ + promise?: Promise; seen?: boolean; } diff --git a/packages/inngest/src/components/execution/v1.ts b/packages/inngest/src/components/execution/v1.ts index 639baced3..e79a53591 100644 --- a/packages/inngest/src/components/execution/v1.ts +++ b/packages/inngest/src/components/execution/v1.ts @@ -864,6 +864,7 @@ class V1InngestExecution extends InngestExecution implements IInngestExecution { hashedId, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument fn: opts?.fn ? () => opts.fn?.(...args) : undefined, + promise, fulfilled: Boolean(stepState), displayName: opId.displayName ?? opId.id, handled: false,