kb-server 0.0.1-beta.42 → 0.0.1-beta.44

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.
@@ -26,7 +26,7 @@ export interface ICreateServerParams {
26
26
  /**
27
27
  * 超时时间(单位:毫秒)
28
28
  *
29
- * @description 每次推送消息会重置超时时间
29
+ * @description 从第一次推送消息时开始计时,每次推送消息会重置超时时间
30
30
  */
31
31
  timeout?: number;
32
32
  };
@@ -93,11 +93,11 @@ const packSSE = (sseHandlers, options) => {
93
93
  };
94
94
  // 推送消息
95
95
  const push = (data) => {
96
- resetTimeout();
97
96
  if (!isConnected) {
98
97
  logger_1.logger.warning(`连接已关闭: ${requestId}`);
99
98
  return;
100
99
  }
100
+ resetTimeout();
101
101
  const msg = createResponseMsg(data);
102
102
  const response = (0, exports.createSSEMsg)("message", msg);
103
103
  try {
@@ -113,6 +113,8 @@ const packSSE = (sseHandlers, options) => {
113
113
  };
114
114
  // 主动关闭
115
115
  const close = () => {
116
+ if (!isConnected)
117
+ return;
116
118
  logger_1.logger.info(`主动关闭连接: ${requestId}`);
117
119
  // 完成响应
118
120
  took = Date.now() - start;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kb-server",
3
- "version": "0.0.1-beta.42",
3
+ "version": "0.0.1-beta.44",
4
4
  "description": "A fast server for Node.JS,made by express.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {