Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promise warning on dt.confirm #16

Open
ubreddy opened this issue Sep 5, 2018 · 1 comment
Open

Promise warning on dt.confirm #16

ubreddy opened this issue Sep 5, 2018 · 1 comment

Comments

@ubreddy
Copy link

ubreddy commented Sep 5, 2018

Keep getting this warning on Promise...
May be coming from inside the library...
I get this if I use confirm method...

(node:149536) Warning: a promise was created in a handler at net.js:607:20 but was not returned from it, see http://goo.gl/rRqMUw
at RedisClient.ret [as timeAsync] (eval at makeNodePromisifiedEval ( node_modules\bluebird\js\release\promisify.js:184:12), :8:21)
at DTimer._redisTime ( node_modules\dtimer\lib\dtimer.js:164:22)
at DTimer.confirm ( node_modules\dtimer\lib\dtimer.js:331:17)
at DTimer. (/timeout/timer.js:129:16)
at emitOne (events.js:121:20)
at DTimer.emit (events.js:211:7)
at node_modules\dtimer\lib\dtimer.js:427:26
at Array.forEach ()
at self._pub.evalshaAsync.then.interval ( node_modules\dtimer\lib\dtimer.js:419:28)
at normal_reply ( node_modules\redis\index.js:726:21)
at RedisClient.return_reply ( node_modules\redis\index.js:824:9)
at JavascriptRedisParser.returnReply ( node_modules\redis\index.js:192:18)
at JavascriptRedisParser.execute ( node_modules\redis-parser\lib\parser.js:553:10)
From previous event:
at node_modules\dtimer\lib\dtimer.js:416:10
at normal_reply ( node_modules\redis\index.js:726:21)
at RedisClient.return_reply ( node_modules\redis\index.js:824:9)
at JavascriptRedisParser.returnReply ( node_modules\redis\index.js:192:18)
at JavascriptRedisParser.execute ( node_modules\redis-parser\lib\parser.js:574:12)
at Socket. ( node_modules\redis\index.js:274:27)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at TCP.onread (net.js:607:20)
From previous event:
at DTimer._onTimeout ( node_modules\dtimer\lib\dtimer.js:402:6)
at ontimeout (timers.js:482:11)
at tryOnTimeout (timers.js:317:5)
at Timer.listOnTimeout (timers.js:277:5)

@enobufs
Copy link
Owner

enobufs commented Oct 20, 2018

I see this warning in my unit tests also when I set the bluebird warnings to true, but I am not sure about the cause of the warning.

In my tests, too, the warnings occur inside dt.confirm() method. I realize, the call is made on the event 'event', and dt.confirm() is the only one that is called on the event in my tests.

So, I tried to delay the emission of the event using process.nextTick(), then warnings were gone. I still have no idea why that is, but at least there's a way to get around the warning.

diff --git a/lib/dtimer.js b/lib/dtimer.js
index 4bd256a..ca31996 100644
--- a/lib/dtimer.js
+++ b/lib/dtimer.js
@@ -424,7 +424,9 @@ DTimer.prototype._onTimeout = function () {
                         debug(self._id+': fail to parse event. ' + JSON.stringify(e));
                         return;
                     }
-                    self.emit('event', ev);
+                    process.nextTick(function () {
+                        self.emit('event', ev);
+                    });
                 });
             }
         }, function (err) {

The above change is reasonable, but the warning might just be spurious (harmless). Let me think about it a bit more before deciding what to do.

@ubreddy, If you have a chance, try this branch bugfix/issue_16 and let me know if that works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants