@cedarjs/api-server 5.0.0-canary.2548 → 5.0.0-canary.2551

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/bin.js CHANGED
@@ -581,17 +581,24 @@ async function redwoodFastifyGraphQLServer(fastify2, options) {
581
581
  fastify2.route({
582
582
  url: `${redwoodOptions.apiRootPath}${graphqlEndpoint}${routePath}`,
583
583
  method,
584
- handler: async (req, _reply) => {
585
- const request = createFetchRequest(req);
584
+ handler: async (req, reply) => {
585
+ const request = createFetchRequest(req, reply);
586
586
  const cedarContext = await buildCedarContext2(request, {
587
587
  authDecoder: graphqlOptions.authDecoder
588
588
  });
589
- return yoga.handle(request, {
590
- request,
591
- cedarContext,
592
- event: lambdaEventForFastifyRequest(req),
593
- requestContext: void 0
594
- });
589
+ try {
590
+ return await yoga.handle(request, {
591
+ request,
592
+ cedarContext,
593
+ event: lambdaEventForFastifyRequest(req),
594
+ requestContext: void 0
595
+ });
596
+ } catch (e) {
597
+ if (!!e && typeof e === "object" && "code" in e && e.code === "ERR_STREAM_PREMATURE_CLOSE") {
598
+ return new Response(null, { status: 499 });
599
+ }
600
+ throw e;
601
+ }
595
602
  }
596
603
  });
597
604
  }
@@ -612,13 +619,20 @@ async function redwoodFastifyGraphQLServer(fastify2, options) {
612
619
  function trimSlashes(path5) {
613
620
  return path5.replace(/^\/|\/$/g, "");
614
621
  }
615
- function createFetchRequest(req) {
622
+ function createFetchRequest(req, reply) {
623
+ const controller = new AbortController();
624
+ reply.raw.on("close", () => {
625
+ if (!reply.raw.writableFinished) {
626
+ controller.abort();
627
+ }
628
+ });
616
629
  const requestBody = req.method === "GET" || req.method === "HEAD" ? void 0 : typeof req.body === "string" ? req.body : req.body ? JSON.stringify(req.body) : void 0;
617
630
  const href = `${req.protocol}://${req.hostname}${req.raw.url ?? "/"}`;
618
631
  return new Request(href, {
619
632
  method: req.method,
620
633
  headers: req.headers,
621
- body: requestBody
634
+ body: requestBody,
635
+ signal: controller.signal
622
636
  });
623
637
  }
624
638
  var init_graphql = __esm({
package/dist/cjs/bin.js CHANGED
@@ -595,17 +595,24 @@ async function redwoodFastifyGraphQLServer(fastify2, options) {
595
595
  fastify2.route({
596
596
  url: `${redwoodOptions.apiRootPath}${graphqlEndpoint}${routePath}`,
597
597
  method,
598
- handler: async (req, _reply) => {
599
- const request = createFetchRequest(req);
598
+ handler: async (req, reply) => {
599
+ const request = createFetchRequest(req, reply);
600
600
  const cedarContext = await (0, import_runtime2.buildCedarContext)(request, {
601
601
  authDecoder: graphqlOptions.authDecoder
602
602
  });
603
- return yoga.handle(request, {
604
- request,
605
- cedarContext,
606
- event: lambdaEventForFastifyRequest(req),
607
- requestContext: void 0
608
- });
603
+ try {
604
+ return await yoga.handle(request, {
605
+ request,
606
+ cedarContext,
607
+ event: lambdaEventForFastifyRequest(req),
608
+ requestContext: void 0
609
+ });
610
+ } catch (e) {
611
+ if (!!e && typeof e === "object" && "code" in e && e.code === "ERR_STREAM_PREMATURE_CLOSE") {
612
+ return new Response(null, { status: 499 });
613
+ }
614
+ throw e;
615
+ }
609
616
  }
610
617
  });
611
618
  }
@@ -626,13 +633,20 @@ async function redwoodFastifyGraphQLServer(fastify2, options) {
626
633
  function trimSlashes(path5) {
627
634
  return path5.replace(/^\/|\/$/g, "");
628
635
  }
629
- function createFetchRequest(req) {
636
+ function createFetchRequest(req, reply) {
637
+ const controller = new AbortController();
638
+ reply.raw.on("close", () => {
639
+ if (!reply.raw.writableFinished) {
640
+ controller.abort();
641
+ }
642
+ });
630
643
  const requestBody = req.method === "GET" || req.method === "HEAD" ? void 0 : typeof req.body === "string" ? req.body : req.body ? JSON.stringify(req.body) : void 0;
631
644
  const href = `${req.protocol}://${req.hostname}${req.raw.url ?? "/"}`;
632
645
  return new Request(href, {
633
646
  method: req.method,
634
647
  headers: req.headers,
635
- body: requestBody
648
+ body: requestBody,
649
+ signal: controller.signal
636
650
  });
637
651
  }
638
652
  var import_node_url2, import_multipart, import_url_data2, import_fast_glob2, import_runtime2, import_store3, import_helpers3, import_graphql_server, import_project_config4;
@@ -1 +1 @@
1
- {"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../../src/plugins/graphql.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAA+B,MAAM,SAAS,CAAA;AAO3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAKjE,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE;QACP,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,OAAO,CAAC,EAAE,kBAAkB,CAAA;KAC7B,CAAA;CACF;AAED,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,4BAA4B,iBAuGtC"}
1
+ {"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../../src/plugins/graphql.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,SAAS,CAAA;AAOhB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAKjE,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE;QACP,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,OAAO,CAAC,EAAE,kBAAkB,CAAA;KAC7B,CAAA;CACF;AAED,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,4BAA4B,iBAuHtC"}
@@ -75,17 +75,24 @@ async function redwoodFastifyGraphQLServer(fastify, options) {
75
75
  fastify.route({
76
76
  url: `${redwoodOptions.apiRootPath}${graphqlEndpoint}${routePath}`,
77
77
  method,
78
- handler: async (req, _reply) => {
79
- const request = createFetchRequest(req);
78
+ handler: async (req, reply) => {
79
+ const request = createFetchRequest(req, reply);
80
80
  const cedarContext = await (0, import_runtime.buildCedarContext)(request, {
81
81
  authDecoder: graphqlOptions.authDecoder
82
82
  });
83
- return yoga.handle(request, {
84
- request,
85
- cedarContext,
86
- event: (0, import_awsLambdaFastify.lambdaEventForFastifyRequest)(req),
87
- requestContext: void 0
88
- });
83
+ try {
84
+ return await yoga.handle(request, {
85
+ request,
86
+ cedarContext,
87
+ event: (0, import_awsLambdaFastify.lambdaEventForFastifyRequest)(req),
88
+ requestContext: void 0
89
+ });
90
+ } catch (e) {
91
+ if (!!e && typeof e === "object" && "code" in e && e.code === "ERR_STREAM_PREMATURE_CLOSE") {
92
+ return new Response(null, { status: 499 });
93
+ }
94
+ throw e;
95
+ }
89
96
  }
90
97
  });
91
98
  }
@@ -106,13 +113,20 @@ async function redwoodFastifyGraphQLServer(fastify, options) {
106
113
  function trimSlashes(path) {
107
114
  return path.replace(/^\/|\/$/g, "");
108
115
  }
109
- function createFetchRequest(req) {
116
+ function createFetchRequest(req, reply) {
117
+ const controller = new AbortController();
118
+ reply.raw.on("close", () => {
119
+ if (!reply.raw.writableFinished) {
120
+ controller.abort();
121
+ }
122
+ });
110
123
  const requestBody = req.method === "GET" || req.method === "HEAD" ? void 0 : typeof req.body === "string" ? req.body : req.body ? JSON.stringify(req.body) : void 0;
111
124
  const href = `${req.protocol}://${req.hostname}${req.raw.url ?? "/"}`;
112
125
  return new Request(href, {
113
126
  method: req.method,
114
127
  headers: req.headers,
115
- body: requestBody
128
+ body: requestBody,
129
+ signal: controller.signal
116
130
  });
117
131
  }
118
132
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/plugins/graphql.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAA+B,MAAM,SAAS,CAAA;AAO3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAKjE,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE;QACP,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,OAAO,CAAC,EAAE,kBAAkB,CAAA;KAC7B,CAAA;CACF;AAED,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,4BAA4B,iBAuGtC"}
1
+ {"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/plugins/graphql.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,SAAS,CAAA;AAOhB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAKjE,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE;QACP,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,OAAO,CAAC,EAAE,kBAAkB,CAAA;KAC7B,CAAA;CACF;AAED,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,4BAA4B,iBAuHtC"}
@@ -42,17 +42,24 @@ async function redwoodFastifyGraphQLServer(fastify, options) {
42
42
  fastify.route({
43
43
  url: `${redwoodOptions.apiRootPath}${graphqlEndpoint}${routePath}`,
44
44
  method,
45
- handler: async (req, _reply) => {
46
- const request = createFetchRequest(req);
45
+ handler: async (req, reply) => {
46
+ const request = createFetchRequest(req, reply);
47
47
  const cedarContext = await buildCedarContext(request, {
48
48
  authDecoder: graphqlOptions.authDecoder
49
49
  });
50
- return yoga.handle(request, {
51
- request,
52
- cedarContext,
53
- event: lambdaEventForFastifyRequest(req),
54
- requestContext: void 0
55
- });
50
+ try {
51
+ return await yoga.handle(request, {
52
+ request,
53
+ cedarContext,
54
+ event: lambdaEventForFastifyRequest(req),
55
+ requestContext: void 0
56
+ });
57
+ } catch (e) {
58
+ if (!!e && typeof e === "object" && "code" in e && e.code === "ERR_STREAM_PREMATURE_CLOSE") {
59
+ return new Response(null, { status: 499 });
60
+ }
61
+ throw e;
62
+ }
56
63
  }
57
64
  });
58
65
  }
@@ -73,13 +80,20 @@ async function redwoodFastifyGraphQLServer(fastify, options) {
73
80
  function trimSlashes(path) {
74
81
  return path.replace(/^\/|\/$/g, "");
75
82
  }
76
- function createFetchRequest(req) {
83
+ function createFetchRequest(req, reply) {
84
+ const controller = new AbortController();
85
+ reply.raw.on("close", () => {
86
+ if (!reply.raw.writableFinished) {
87
+ controller.abort();
88
+ }
89
+ });
77
90
  const requestBody = req.method === "GET" || req.method === "HEAD" ? void 0 : typeof req.body === "string" ? req.body : req.body ? JSON.stringify(req.body) : void 0;
78
91
  const href = `${req.protocol}://${req.hostname}${req.raw.url ?? "/"}`;
79
92
  return new Request(href, {
80
93
  method: req.method,
81
94
  headers: req.headers,
82
- body: requestBody
95
+ body: requestBody,
96
+ signal: controller.signal
83
97
  });
84
98
  }
85
99
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/api-server",
3
- "version": "5.0.0-canary.2548",
3
+ "version": "5.0.0-canary.2551",
4
4
  "description": "CedarJS's HTTP server for Serverless Functions",
5
5
  "repository": {
6
6
  "type": "git",
@@ -133,11 +133,11 @@
133
133
  "test:watch": "vitest watch"
134
134
  },
135
135
  "dependencies": {
136
- "@cedarjs/context": "5.0.0-canary.2548",
137
- "@cedarjs/fastify-web": "5.0.0-canary.2548",
138
- "@cedarjs/internal": "5.0.0-canary.2548",
139
- "@cedarjs/project-config": "5.0.0-canary.2548",
140
- "@cedarjs/web-server": "5.0.0-canary.2548",
136
+ "@cedarjs/context": "5.0.0-canary.2551",
137
+ "@cedarjs/fastify-web": "5.0.0-canary.2551",
138
+ "@cedarjs/internal": "5.0.0-canary.2551",
139
+ "@cedarjs/project-config": "5.0.0-canary.2551",
140
+ "@cedarjs/web-server": "5.0.0-canary.2551",
141
141
  "@fastify/multipart": "9.4.0",
142
142
  "@fastify/url-data": "6.0.3",
143
143
  "ansis": "4.2.0",
@@ -155,7 +155,7 @@
155
155
  "yargs": "17.7.2"
156
156
  },
157
157
  "devDependencies": {
158
- "@cedarjs/framework-tools": "5.0.0-canary.2548",
158
+ "@cedarjs/framework-tools": "5.0.0-canary.2551",
159
159
  "@types/aws-lambda": "8.10.162",
160
160
  "@types/dotenv-defaults": "^5.0.0",
161
161
  "@types/split2": "4.2.3",