dtimer icon indicating copy to clipboard operation
dtimer copied to clipboard

Promise warning on dt.confirm

Open ubreddy opened this issue 7 years ago • 1 comments

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)

ubreddy avatar Sep 05 '18 05:09 ubreddy

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.

enobufs avatar Oct 20 '18 06:10 enobufs