@cedarjs/api-server 6.0.0-rc.221 → 6.0.0-rc.241
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 +15 -2
- package/dist/plugins/graphql.d.ts +16 -0
- package/dist/plugins/graphql.d.ts.map +1 -1
- package/dist/plugins/graphql.js +15 -2
- package/package.json +9 -9
package/dist/bin.js
CHANGED
|
@@ -573,7 +573,8 @@ var init_api = __esm({
|
|
|
573
573
|
// src/plugins/graphql.ts
|
|
574
574
|
var graphql_exports = {};
|
|
575
575
|
__export(graphql_exports, {
|
|
576
|
-
cedarFastifyGraphQLServer: () => cedarFastifyGraphQLServer
|
|
576
|
+
cedarFastifyGraphQLServer: () => cedarFastifyGraphQLServer,
|
|
577
|
+
isClientDisconnectError: () => isClientDisconnectError
|
|
577
578
|
});
|
|
578
579
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
579
580
|
import fastifyMultiPart from "@fastify/multipart";
|
|
@@ -631,7 +632,7 @@ async function cedarFastifyGraphQLServer(fastify2, options) {
|
|
|
631
632
|
requestContext: void 0
|
|
632
633
|
});
|
|
633
634
|
} catch (e) {
|
|
634
|
-
if (
|
|
635
|
+
if (isClientDisconnectError(e)) {
|
|
635
636
|
return new Response(null, { status: 499 });
|
|
636
637
|
}
|
|
637
638
|
throw e;
|
|
@@ -658,6 +659,18 @@ async function cedarFastifyGraphQLServer(fastify2, options) {
|
|
|
658
659
|
function trimSlashes(path6) {
|
|
659
660
|
return path6.replace(/^\/|\/$/g, "");
|
|
660
661
|
}
|
|
662
|
+
function isClientDisconnectError(e) {
|
|
663
|
+
if (!e || typeof e !== "object") {
|
|
664
|
+
return false;
|
|
665
|
+
}
|
|
666
|
+
if ("code" in e && e.code === "ERR_STREAM_PREMATURE_CLOSE") {
|
|
667
|
+
return true;
|
|
668
|
+
}
|
|
669
|
+
if (e instanceof DOMException && e.name === "AbortError") {
|
|
670
|
+
return true;
|
|
671
|
+
}
|
|
672
|
+
return false;
|
|
673
|
+
}
|
|
661
674
|
function createFetchRequest(req, reply) {
|
|
662
675
|
const controller = new AbortController();
|
|
663
676
|
reply.raw.on("close", () => {
|
|
@@ -7,4 +7,20 @@ export interface CedarFastifyGraphQLOptions {
|
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
9
|
export declare function cedarFastifyGraphQLServer(fastify: FastifyInstance, options: CedarFastifyGraphQLOptions): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Detects errors that indicate the client disconnected before the response
|
|
12
|
+
* finished, rather than a genuine server-side failure.
|
|
13
|
+
*
|
|
14
|
+
* `ERR_STREAM_PREMATURE_CLOSE` can surface from the underlying Node stream
|
|
15
|
+
* closing early. The `DOMException` named `AbortError` is thrown by Yoga
|
|
16
|
+
* when the AbortSignal wired up in `createFetchRequest`'s
|
|
17
|
+
* `reply.raw.on('close', ...)` handler is aborted, which only happens when
|
|
18
|
+
* the client itself has gone away.
|
|
19
|
+
*
|
|
20
|
+
* The `DOMException` check (rather than just `name === 'AbortError'`) is
|
|
21
|
+
* deliberate: a resolver or hook could throw a plain `Error` renamed to
|
|
22
|
+
* `AbortError`, which would otherwise be misclassified as a benign
|
|
23
|
+
* disconnect and hide a real server-side failure behind a 499.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isClientDisconnectError(e: unknown): boolean;
|
|
10
26
|
//# sourceMappingURL=graphql.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,0BAA0B;IACzC,KAAK,EAAE;QACL,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,OAAO,CAAC,EAAE,kBAAkB,CAAA;KAC7B,CAAA;CACF;AAED,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,0BAA0B,
|
|
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,0BAA0B;IACzC,KAAK,EAAE;QACL,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,OAAO,CAAC,EAAE,kBAAkB,CAAA;KAC7B,CAAA;CACF;AAED,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,0BAA0B,iBA0HpC;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAc3D"}
|
package/dist/plugins/graphql.js
CHANGED
|
@@ -55,7 +55,7 @@ async function cedarFastifyGraphQLServer(fastify, options) {
|
|
|
55
55
|
requestContext: void 0
|
|
56
56
|
});
|
|
57
57
|
} catch (e) {
|
|
58
|
-
if (
|
|
58
|
+
if (isClientDisconnectError(e)) {
|
|
59
59
|
return new Response(null, { status: 499 });
|
|
60
60
|
}
|
|
61
61
|
throw e;
|
|
@@ -82,6 +82,18 @@ async function cedarFastifyGraphQLServer(fastify, options) {
|
|
|
82
82
|
function trimSlashes(path) {
|
|
83
83
|
return path.replace(/^\/|\/$/g, "");
|
|
84
84
|
}
|
|
85
|
+
function isClientDisconnectError(e) {
|
|
86
|
+
if (!e || typeof e !== "object") {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
if ("code" in e && e.code === "ERR_STREAM_PREMATURE_CLOSE") {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
if (e instanceof DOMException && e.name === "AbortError") {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
85
97
|
function createFetchRequest(req, reply) {
|
|
86
98
|
const controller = new AbortController();
|
|
87
99
|
reply.raw.on("close", () => {
|
|
@@ -99,5 +111,6 @@ function createFetchRequest(req, reply) {
|
|
|
99
111
|
});
|
|
100
112
|
}
|
|
101
113
|
export {
|
|
102
|
-
cedarFastifyGraphQLServer
|
|
114
|
+
cedarFastifyGraphQLServer,
|
|
115
|
+
isClientDisconnectError
|
|
103
116
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/api-server",
|
|
3
|
-
"version": "6.0.0-rc.
|
|
3
|
+
"version": "6.0.0-rc.241",
|
|
4
4
|
"description": "CedarJS's HTTP server for Serverless Functions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -92,11 +92,11 @@
|
|
|
92
92
|
"test:watch": "vitest watch"
|
|
93
93
|
},
|
|
94
94
|
"dependencies": {
|
|
95
|
-
"@cedarjs/api": "6.0.0-rc.
|
|
96
|
-
"@cedarjs/context": "6.0.0-rc.
|
|
97
|
-
"@cedarjs/fastify-web": "6.0.0-rc.
|
|
98
|
-
"@cedarjs/project-config": "6.0.0-rc.
|
|
99
|
-
"@cedarjs/web-server": "6.0.0-rc.
|
|
95
|
+
"@cedarjs/api": "6.0.0-rc.241",
|
|
96
|
+
"@cedarjs/context": "6.0.0-rc.241",
|
|
97
|
+
"@cedarjs/fastify-web": "6.0.0-rc.241",
|
|
98
|
+
"@cedarjs/project-config": "6.0.0-rc.241",
|
|
99
|
+
"@cedarjs/web-server": "6.0.0-rc.241",
|
|
100
100
|
"@fastify/multipart": "9.4.0",
|
|
101
101
|
"@fastify/url-data": "6.0.3",
|
|
102
102
|
"ansis": "4.3.1",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"yargs": "17.7.3"
|
|
114
114
|
},
|
|
115
115
|
"devDependencies": {
|
|
116
|
-
"@cedarjs/framework-tools": "6.0.0-rc.
|
|
116
|
+
"@cedarjs/framework-tools": "6.0.0-rc.241",
|
|
117
117
|
"@types/aws-lambda": "8.10.162",
|
|
118
118
|
"@types/dotenv-defaults": "^5.0.0",
|
|
119
119
|
"@types/split2": "4.2.3",
|
|
@@ -123,12 +123,12 @@
|
|
|
123
123
|
"memfs": "4.64.0",
|
|
124
124
|
"pino": "9.7.0",
|
|
125
125
|
"pino-abstract-transport": "1.2.0",
|
|
126
|
-
"publint": "0.3.
|
|
126
|
+
"publint": "0.3.23",
|
|
127
127
|
"typescript": "5.9.3",
|
|
128
128
|
"vitest": "4.1.10"
|
|
129
129
|
},
|
|
130
130
|
"peerDependencies": {
|
|
131
|
-
"@cedarjs/graphql-server": "6.0.0-rc.
|
|
131
|
+
"@cedarjs/graphql-server": "6.0.0-rc.241"
|
|
132
132
|
},
|
|
133
133
|
"peerDependenciesMeta": {
|
|
134
134
|
"@cedarjs/graphql-server": {
|