@mastra/deployer 1.83.0-alpha.2 → 1.83.0-alpha.3

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.
@@ -1,5 +1,5 @@
1
1
  import type { Mastra } from '@mastra/core/mastra';
2
- import type { HonoBindings, HonoVariables } from '../_types/@mastra_hono@1.7.25-alpha.2/dist/index.js';
2
+ import type { HonoBindings, HonoVariables } from '../_types/@mastra_hono@1.7.25-alpha.3/dist/index.js';
3
3
  import { Hono } from 'hono';
4
4
  import type { ServerBundleOptions } from './types.js';
5
5
  type Bindings = HonoBindings;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIlD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAKhE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAmB5B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAoBnD,KAAK,QAAQ,GAAG,YAAY,CAAC;AAE7B,KAAK,SAAS,GAAG,aAAa,GAAG;IAC/B,OAAO,EAAE,GAAG,CAAC;QAAE,UAAU,EAAE,+BAA+B,CAAA;KAAE,CAAC,CAAC;CAC/D,CAAC;AA8CF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,wCAmB/D;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,mBAER;cAegC,QAAQ;eAAa,SAAS;2CA4bhE;AAED,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAmC,mDAmMlG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIlD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAKhE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAmB5B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAoBnD,KAAK,QAAQ,GAAG,YAAY,CAAC;AAE7B,KAAK,SAAS,GAAG,aAAa,GAAG;IAC/B,OAAO,EAAE,GAAG,CAAC;QAAE,UAAU,EAAE,+BAA+B,CAAA;KAAE,CAAC,CAAC;CAC/D,CAAC;AAiDF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,wCAmB/D;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,mBAER;cAegC,QAAQ;eAAa,SAAS;2CA4bhE;AAED,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAmC,mDAoMlG"}
@@ -3609,6 +3609,27 @@ const BODY_METHODS = /* @__PURE__ */ new Set([
3609
3609
  "PATCH",
3610
3610
  "DELETE"
3611
3611
  ]);
3612
+ /**
3613
+ * Cancels a response body the runtime never started reading once the request aborts. @hono/node-server skips the body
3614
+ * of a request that closed while the route handler ran without cancelling it. A body the runtime already reads is
3615
+ * locked, and the runtime cancels that one itself on disconnect.
3616
+ *
3617
+ * `body` is only read after the abort: reading it earlier turns off @hono/node-server's fast path for string and byte
3618
+ * bodies, which is what sets `Content-Length` and the default content type.
3619
+ */
3620
+ function cancelUnreadBodyOnAbort(response, signal) {
3621
+ const cancel = () => {
3622
+ let body;
3623
+ try {
3624
+ body = response.body;
3625
+ } catch {
3626
+ return;
3627
+ }
3628
+ if (body && !body.locked) body.cancel("request aborted").catch(() => {});
3629
+ };
3630
+ if (signal.aborted) cancel();
3631
+ else signal.addEventListener("abort", cancel, { once: true });
3632
+ }
3612
3633
  var MastraServer$2 = class extends MastraServer {
3613
3634
  createContextMiddleware() {
3614
3635
  return async (c, next) => {
@@ -3670,12 +3691,16 @@ var MastraServer$2 = class extends MastraServer {
3670
3691
  } else res.header("Content-Type", "text/plain");
3671
3692
  res.header("Transfer-Encoding", "chunked");
3672
3693
  return stream(res, async (stream) => {
3673
- if (streamFormat === "sse" && route.sseFlushOnConnect) await stream.write(": connected\n\n");
3674
3694
  const reader = (result instanceof ReadableStream ? result : result.fullStream).getReader();
3675
3695
  stream.onAbort(() => {
3676
3696
  reader.cancel("request aborted").catch(() => {});
3677
3697
  });
3698
+ const signal = res.req.raw.signal;
3699
+ const abortStream = () => stream.abort();
3700
+ if (signal.aborted) abortStream();
3701
+ else signal.addEventListener("abort", abortStream, { once: true });
3678
3702
  try {
3703
+ if (streamFormat === "sse" && route.sseFlushOnConnect) await stream.write(": connected\n\n");
3679
3704
  while (true) {
3680
3705
  const { done, value } = await reader.read();
3681
3706
  if (done) break;
@@ -3705,6 +3730,7 @@ var MastraServer$2 = class extends MastraServer {
3705
3730
  stack: error.stack
3706
3731
  } : error });
3707
3732
  } finally {
3733
+ signal.removeEventListener("abort", abortStream);
3708
3734
  await stream.close();
3709
3735
  }
3710
3736
  }, async (err) => {
@@ -3780,8 +3806,11 @@ var MastraServer$2 = class extends MastraServer {
3780
3806
  }
3781
3807
  if (route.responseType === "json") return response.json(result, 200);
3782
3808
  else if (route.responseType === "stream") return this.stream(route, response, result);
3783
- else if (route.responseType === "datastream-response") return result;
3784
- else if (route.responseType === "mcp-http") {
3809
+ else if (route.responseType === "datastream-response") {
3810
+ const fetchResponse = result;
3811
+ cancelUnreadBodyOnAbort(fetchResponse, response.req.raw.signal);
3812
+ return fetchResponse;
3813
+ } else if (route.responseType === "mcp-http") {
3785
3814
  const { server, httpPath, mcpOptions: routeMcpOptions } = result;
3786
3815
  const { req, res } = toReqRes(response.req.raw);
3787
3816
  const { setRequestAuth, ...options } = {
@@ -4854,8 +4883,9 @@ const DEFAULT_CORS_ALLOW_HEADERS = [
4854
4883
  const DEFAULT_CORS_EXPOSE_HEADERS = ["Content-Length", "X-Requested-With"];
4855
4884
  function getCorsConfig(serverCors, credentialsDefault) {
4856
4885
  const userCors = serverCors && typeof serverCors === "object" ? serverCors : void 0;
4857
- const origin = userCors && "origin" in userCors && userCors.origin ? userCors.origin : credentialsDefault ? (requestOrigin) => requestOrigin || void 0 : "*";
4858
- const credentials = userCors && "credentials" in userCors ? userCors.credentials : credentialsDefault;
4886
+ const hasExplicitOrigin = !!(userCors && "origin" in userCors && userCors.origin);
4887
+ const origin = hasExplicitOrigin ? userCors.origin : credentialsDefault ? (requestOrigin) => requestOrigin || void 0 : "*";
4888
+ const credentials = userCors && "credentials" in userCors ? userCors.credentials : credentialsDefault && hasExplicitOrigin;
4859
4889
  return {
4860
4890
  origin,
4861
4891
  allowMethods: DEFAULT_CORS_ALLOW_METHODS,
@@ -5166,7 +5196,7 @@ async function createNodeServer(mastra, options = { tools: {} }) {
5166
5196
  import("@mastra/core/telemetry").then(({ syncUsageTelemetry }) => syncUsageTelemetry(mastra)).catch(() => {});
5167
5197
  import("@mastra/core/telemetry").then(({ syncFeatureUsageTelemetry }) => syncFeatureUsageTelemetry(mastra)).catch(() => {});
5168
5198
  if (serverOptions?.handleShutdownSignals !== false) {
5169
- const CORE_SHUTDOWN_TIMEOUT_MS = 5e3;
5199
+ const CORE_SHUTDOWN_TIMEOUT_MS = 6500;
5170
5200
  const timedOut = Symbol("shutdown-timeout");
5171
5201
  const race = async (work, ms) => {
5172
5202
  let timeout;