kb-server 0.0.1-beta.39 → 0.0.1-beta.40
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.
|
@@ -62,12 +62,6 @@ const packSSE = (sseHandlers, options) => {
|
|
|
62
62
|
if (typeof execution !== "function") {
|
|
63
63
|
throw new create_errors_1.CommonErrors.ResourceNotFound.APINotFound();
|
|
64
64
|
}
|
|
65
|
-
// 写头
|
|
66
|
-
res.writeHead(200, {
|
|
67
|
-
"Content-Type": "text/event-stream",
|
|
68
|
-
"Cache-Control": "no-cache",
|
|
69
|
-
Connection: "keep-alive",
|
|
70
|
-
});
|
|
71
65
|
const abortController = new AbortController();
|
|
72
66
|
// 连接断开
|
|
73
67
|
let isConnected = true;
|
|
@@ -79,6 +73,12 @@ const packSSE = (sseHandlers, options) => {
|
|
|
79
73
|
logger_1.logger.info(`耗时:${took} ms - ${requestId}`);
|
|
80
74
|
return res.end();
|
|
81
75
|
});
|
|
76
|
+
// 写头
|
|
77
|
+
res.writeHead(200, {
|
|
78
|
+
"Content-Type": "text/event-stream",
|
|
79
|
+
"Cache-Control": "no-cache",
|
|
80
|
+
Connection: "keep-alive",
|
|
81
|
+
});
|
|
82
82
|
// 推送消息
|
|
83
83
|
const push = (data) => {
|
|
84
84
|
if (!isConnected) {
|
|
@@ -86,9 +86,10 @@ const packSSE = (sseHandlers, options) => {
|
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
88
|
const msg = createResponseMsg(data);
|
|
89
|
+
const response = (0, exports.createSSEMsg)("message", msg);
|
|
89
90
|
try {
|
|
90
|
-
res.write(
|
|
91
|
-
logger_1.logger.info(`推送数据: ${
|
|
91
|
+
res.write(response);
|
|
92
|
+
logger_1.logger.info(`推送数据: ${response}`);
|
|
92
93
|
}
|
|
93
94
|
catch (error) {
|
|
94
95
|
if (error.code === "EPIPE" || error.code === "ECONNRESET") {
|