faye-redis-ng 1.0.1 → 1.0.2
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/README.md +4 -4
- package/faye-redis.js +19 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# faye-redis-ng
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
4
|
[](https://nodejs.org)
|
|
5
|
-
[](https://github.com/7a6163/faye-redis-node/actions)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
|
|
8
8
|
**Next Generation** Redis backend engine for [Faye](http://faye.jcoglan.com) - A modern, maintained fork with Redis v4 support, ES6+ syntax, and automatic reconnection.
|
|
9
9
|
|
|
10
10
|
## 🎉 What's New in NG (Next Generation)
|
|
11
11
|
|
|
12
|
-
This is a modernized fork of the original [faye-redis](https://github.com/
|
|
12
|
+
This is a modernized fork of the original [faye-redis](https://github.com/7a6163/faye-redis-node) with significant improvements:
|
|
13
13
|
|
|
14
14
|
### ✨ Key Improvements
|
|
15
15
|
|
|
@@ -207,7 +207,7 @@ Contributions are welcome! This is a community-maintained fork. Please:
|
|
|
207
207
|
|
|
208
208
|
## Support
|
|
209
209
|
|
|
210
|
-
- **Issues**: [GitHub Issues](http://github.com/
|
|
210
|
+
- **Issues**: [GitHub Issues](http://github.com/7a6163/faye-redis-node/issues)
|
|
211
211
|
- **Original Project**: [faye-redis](https://github.com/faye/faye-redis-node)
|
|
212
212
|
|
|
213
213
|
---
|
package/faye-redis.js
CHANGED
|
@@ -67,25 +67,32 @@ class Engine {
|
|
|
67
67
|
this._initialized = true;
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
+
// Track if we've already set up subscriptions to prevent duplicates
|
|
71
|
+
this._subscriptionsSetUp = false;
|
|
72
|
+
|
|
70
73
|
this._subscriber.on('ready', async () => {
|
|
71
74
|
console.log('Redis subscriber ready');
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
75
|
+
// Only re-subscribe after reconnection (not on initial connection)
|
|
76
|
+
if (this._subscriptionsSetUp) {
|
|
77
|
+
console.log('Redis subscriber reconnected, re-subscribing...');
|
|
78
|
+
try {
|
|
79
|
+
await this._subscriber.subscribe(this._messageChannel, (message) => {
|
|
80
|
+
this.emptyQueue(message);
|
|
81
|
+
});
|
|
82
|
+
await this._subscriber.subscribe(this._closeChannel, (message) => {
|
|
83
|
+
this._server.trigger('close', message);
|
|
84
|
+
});
|
|
85
|
+
this._initialized = true;
|
|
86
|
+
} catch (err) {
|
|
87
|
+
console.error('Error re-subscribing after reconnection:', err);
|
|
88
|
+
}
|
|
83
89
|
}
|
|
84
90
|
});
|
|
85
91
|
|
|
86
92
|
await this._redis.connect();
|
|
87
93
|
await this._subscriber.connect();
|
|
88
94
|
|
|
95
|
+
// Initial subscription (only once)
|
|
89
96
|
await this._subscriber.subscribe(this._messageChannel, (message) => {
|
|
90
97
|
this.emptyQueue(message);
|
|
91
98
|
});
|
|
@@ -94,6 +101,7 @@ class Engine {
|
|
|
94
101
|
this._server.trigger('close', message);
|
|
95
102
|
});
|
|
96
103
|
|
|
104
|
+
this._subscriptionsSetUp = true;
|
|
97
105
|
this._initialized = true;
|
|
98
106
|
}
|
|
99
107
|
|