@dainprotocol/tunnel 1.1.16 → 1.1.17
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/server/index.js +9 -1
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -324,11 +324,14 @@ class DainTunnelServer {
|
|
|
324
324
|
}
|
|
325
325
|
handleSSEMessage(data) {
|
|
326
326
|
const connection = this.sseConnections.get(data.id);
|
|
327
|
-
if (!connection)
|
|
327
|
+
if (!connection) {
|
|
328
|
+
console.log(`[SSE Debug] handleSSEMessage: No connection found for ${data.id}, event=${data.event}`);
|
|
328
329
|
return;
|
|
330
|
+
}
|
|
329
331
|
const { res, tunnelId } = connection;
|
|
330
332
|
const clientDisconnected = connection.clientDisconnected;
|
|
331
333
|
const isCloseEvent = data.event === 'close';
|
|
334
|
+
console.log(`[SSE Debug] handleSSEMessage: id=${data.id}, event=${data.event}, clientDisconnected=${clientDisconnected}, isClose=${isCloseEvent}`);
|
|
332
335
|
if (isCloseEvent) {
|
|
333
336
|
const tunnel = this.tunnels.get(tunnelId);
|
|
334
337
|
if (tunnel) {
|
|
@@ -480,12 +483,14 @@ class DainTunnelServer {
|
|
|
480
483
|
body: req.method !== "GET" && req.body ? req.body.toString("base64") : undefined
|
|
481
484
|
}));
|
|
482
485
|
req.on('close', () => {
|
|
486
|
+
console.log(`[SSE Debug] req.close fired for ${sseId} - client disconnected`);
|
|
483
487
|
const connection = this.sseConnections.get(sseId);
|
|
484
488
|
if (connection) {
|
|
485
489
|
connection.clientDisconnected = true;
|
|
486
490
|
// Clean up after a short delay to allow any pending events to be handled
|
|
487
491
|
setTimeout(() => {
|
|
488
492
|
if (this.sseConnections.has(sseId)) {
|
|
493
|
+
console.log(`[SSE Debug] Cleaning up SSE connection ${sseId} after client disconnect`);
|
|
489
494
|
// Decrement request counter for backpressure tracking
|
|
490
495
|
const currentCount = this.tunnelRequestCount.get(tunnelId) || 1;
|
|
491
496
|
this.tunnelRequestCount.set(tunnelId, Math.max(0, currentCount - 1));
|
|
@@ -499,6 +504,9 @@ class DainTunnelServer {
|
|
|
499
504
|
}, 100);
|
|
500
505
|
}
|
|
501
506
|
});
|
|
507
|
+
req.on('error', (err) => {
|
|
508
|
+
console.log(`[SSE Debug] req.error fired for ${sseId}:`, err.message);
|
|
509
|
+
});
|
|
502
510
|
}
|
|
503
511
|
removeTunnel(ws) {
|
|
504
512
|
try {
|