kb-server 0.0.1-beta.24 → 0.0.1-beta.26
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.
|
@@ -81,6 +81,14 @@ const packSSE = (sseHandlers, options) => {
|
|
|
81
81
|
}
|
|
82
82
|
catch (rawError) {
|
|
83
83
|
logger_1.logger.log("error", rawError);
|
|
84
|
+
if (!res.headersSent) {
|
|
85
|
+
// 写请求头
|
|
86
|
+
res.writeHead(200, {
|
|
87
|
+
"Content-Type": "text/event-stream",
|
|
88
|
+
"Cache-Control": "no-cache",
|
|
89
|
+
Connection: "keep-alive",
|
|
90
|
+
});
|
|
91
|
+
}
|
|
84
92
|
// 未知错误
|
|
85
93
|
let error = new create_errors_1.CommonErrors.InternalError.UnknownError();
|
|
86
94
|
// 可控错误
|
|
@@ -93,10 +101,7 @@ const packSSE = (sseHandlers, options) => {
|
|
|
93
101
|
}
|
|
94
102
|
const response = (0, exports.createSSEMessage)("error", JSON.stringify({
|
|
95
103
|
Response: {
|
|
96
|
-
Error: {
|
|
97
|
-
Code: error.code,
|
|
98
|
-
Message: error.message,
|
|
99
|
-
},
|
|
104
|
+
Error: { Code: error.code, Message: error.message },
|
|
100
105
|
RequestId: requestId,
|
|
101
106
|
},
|
|
102
107
|
}));
|
|
@@ -104,8 +109,7 @@ const packSSE = (sseHandlers, options) => {
|
|
|
104
109
|
took = Date.now() - start;
|
|
105
110
|
logger_1.logger.log("info", `发送消息:\n${response}`);
|
|
106
111
|
logger_1.logger.log("info", `耗时:${took} ms - RequestId: ${requestId}`);
|
|
107
|
-
res.
|
|
108
|
-
return res.end();
|
|
112
|
+
return res.send(response);
|
|
109
113
|
}
|
|
110
114
|
};
|
|
111
115
|
};
|