Skip to content

Conversation

@pavelgj
Copy link
Collaborator

@pavelgj pavelgj commented Jun 16, 2025

Fixes #3023

const testFlow = ai.defineFlow(
  { name: 'testFlow' },
  async (input, { abortSignal }) => {
    if (abortSignal.aborted) return; // ABORT
    abortSignal.onabort = () => {
      // ABORT: abortSignal.reason
    };
  }
);
const ctrl = new AbortController();
const responsePromise = testFlow('foo', {
  abortSignal: ctrl.signal,
});
ctrl.abort('reason');

Checklist (if applicable):

@pavelgj pavelgj requested a review from ifielker June 17, 2025 01:15
Copy link
Contributor

@ssbushi ssbushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick LGTM

@pavelgj pavelgj merged commit d76bace into main Jun 18, 2025
5 checks passed
@pavelgj pavelgj deleted the pj/js-abort-signal branch June 18, 2025 17:38
@zerolethanh
Copy link
Contributor

zerolethanh commented Jun 21, 2025

@pavelgj If I send a abortSignal from client (like web or app) as describe here (https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal), this abort function might working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4 participants