@dainprotocol/tunnel 1.1.21 → 1.1.25

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.
@@ -268,9 +268,9 @@ class DainTunnel extends events_1.EventEmitter {
268
268
  }
269
269
  // Stream SSE events to tunnel server
270
270
  let buffer = '';
271
- res.on('data', (chunk) => {
271
+ // Helper to process SSE events from buffer
272
+ const processBuffer = () => {
272
273
  var _a;
273
- buffer += chunk.toString();
274
274
  while (buffer.includes('\n\n')) {
275
275
  const idx = buffer.indexOf('\n\n');
276
276
  const msgData = buffer.substring(0, idx);
@@ -288,9 +288,19 @@ class DainTunnel extends events_1.EventEmitter {
288
288
  this.ws.send(JSON.stringify({ type: 'sse', id: message.id, event, data }));
289
289
  }
290
290
  }
291
+ };
292
+ res.on('data', (chunk) => {
293
+ buffer += chunk.toString();
294
+ processBuffer();
291
295
  });
292
296
  res.on('end', () => {
293
297
  var _a;
298
+ // Process any remaining data in buffer (might be missing final \n\n)
299
+ if (buffer.trim()) {
300
+ // Add missing newlines to ensure processing
301
+ buffer += '\n\n';
302
+ processBuffer();
303
+ }
294
304
  if (((_a = this.ws) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.OPEN) {
295
305
  this.ws.send(JSON.stringify({ type: 'sse', id: message.id, event: 'close', data: '' }));
296
306
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dainprotocol/tunnel",
3
- "version": "1.1.21",
3
+ "version": "1.1.25",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "private": false,
@@ -19,7 +19,7 @@
19
19
  "author": "Ryan",
20
20
  "license": "ISC",
21
21
  "dependencies": {
22
- "@dainprotocol/service-sdk": "2.0.57",
22
+ "@dainprotocol/service-sdk": "2.0.59",
23
23
  "@types/body-parser": "^1.19.5",
24
24
  "@types/cors": "^2.8.17",
25
25
  "@types/eventsource": "^3.0.0",