@mastra/client-js 1.45.0 → 1.45.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5914,6 +5914,7 @@ var AgentControllerSession = class extends BaseResource {
5914
5914
  while (!cancelled) {
5915
5915
  const { done, value } = await reader.read();
5916
5916
  if (done) return cancelled ? { kind: "cancelled" } : { kind: "done" };
5917
+ if (cancelled) return { kind: "cancelled" };
5917
5918
  buffer += decoder.decode(value, { stream: true });
5918
5919
  let separator;
5919
5920
  while ((separator = findFrameSeparator(buffer)) !== null) {
@@ -5929,6 +5930,7 @@ var AgentControllerSession = class extends BaseResource {
5929
5930
  } catch {
5930
5931
  continue;
5931
5932
  }
5933
+ if (cancelled) return { kind: "cancelled" };
5932
5934
  try {
5933
5935
  options.onEvent(event);
5934
5936
  } catch (cause) {
@@ -5981,6 +5983,7 @@ var AgentControllerSession = class extends BaseResource {
5981
5983
  let attempts = 0;
5982
5984
  let reconnectedResponse;
5983
5985
  while (!reconnectedResponse) {
5986
+ if (cancelled) return;
5984
5987
  if (attempts >= reconnectOptions.maxRetries) {
5985
5988
  reportTerminalError(result);
5986
5989
  return;
@@ -6005,6 +6008,10 @@ var AgentControllerSession = class extends BaseResource {
6005
6008
  try {
6006
6009
  options.onReconnect?.();
6007
6010
  } catch {}
6011
+ if (cancelled) {
6012
+ response.body?.cancel().catch(() => {});
6013
+ return;
6014
+ }
6008
6015
  }
6009
6016
  };
6010
6017
  run(firstResponse);