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.
Files changed (3) hide show
  1. package/README.md +4 -4
  2. package/faye-redis.js +19 -11
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # faye-redis-ng
2
2
 
3
- [![npm version](https://badge.fury.io/js/faye-redis-ng.svg)](https://www.npmjs.com/package/faye-redis-ng)
3
+ ![NPM Version](https://img.shields.io/npm/v/faye-redis-ng)
4
4
  [![Node.js Version](https://img.shields.io/node/v/faye-redis-ng.svg)](https://nodejs.org)
5
- [![CI](https://github.com/YOUR-USERNAME/faye-redis-ng/workflows/CI/badge.svg)](https://github.com/YOUR-USERNAME/faye-redis-ng/actions)
5
+ [![CI](https://github.com/7a6163/faye-redis-node/workflows/CI/badge.svg)](https://github.com/7a6163/faye-redis-node/actions)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](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/faye/faye-redis-node) with significant improvements:
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/faye/faye-redis-node/issues)
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
- // Re-subscribe after reconnection
73
- try {
74
- await this._subscriber.subscribe(this._messageChannel, (message) => {
75
- this.emptyQueue(message);
76
- });
77
- await this._subscriber.subscribe(this._closeChannel, (message) => {
78
- this._server.trigger('close', message);
79
- });
80
- this._initialized = true;
81
- } catch (err) {
82
- console.error('Error re-subscribing after reconnection:', err);
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
 
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "realtime"
16
16
  ],
17
17
  "license": "MIT",
18
- "version": "1.0.1",
18
+ "version": "1.0.2",
19
19
  "engines": {
20
20
  "node": ">=22.0.0"
21
21
  },