memjs: timeout but failed to retry until restarting program
Hi, I am using memjs 1.2.0 with memcache. However it sometimes go into fail state for every request until I restart program:
error: socket timed out connecting to server.
at Socket.<anonymous> (/path/node_modules/memjs/lib/memjs/server.js:169:20)
at Object.onceWrapper (events.js:272:13)
at Socket.emit (events.js:180:13)
at Socket.emit (domain.js:421:20)
at Socket._onTimeout (net.js:396:8)
at ontimeout (timers.js:466:11)
at tryOnTimeout (timers.js:304:5)
at Timer.listOnTimeout (timers.js:267:5)
Node v9.9.0
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 5
- Comments: 28 (12 by maintainers)
@UmanShahzad any help is appreciated. I have been unable to reproduce this issue so also a pointer on how to reproduce this error would help a lot.
@tengattack I finally understand what you mean 😃
This would be an option (we actually use event emitters internally) but I don’t think this would be ideal since it would remove choice for the user. For example lets consider a
get
request. It can return a hit, a miss, or an error. If I use an event emitter for errors aget
only returns a hit or a miss. This means as a library developer I need to decide for you how to treat this error. Now in a get request this might be easy (I would treat it as a miss), but what about aset
or anincr
command.So to summarize, an event emitter would basically mean that as the library developer I would have to decide how to treat all errors for the different commands and as a user you only get to react to errors in one way, independently which command they occurred with. The second might not be too mad but the former I am not comfortable doing.
This looks as follows with callbacks:
And with promises:
I tried to reproduce this error again and finally realized that the posted error is an exception that was not caught. Our examples are with callbacks where errors are implicitly handled so I missed that. If you do not use callbacks you need to catch this error with
.catch
for promises or atry/catch
block for async/await and handle the error by getting the info from the ground truth. This is normal caching behavior.