-
Notifications
You must be signed in to change notification settings - Fork 13
Maximum call stack size exceeded #5
Comments
FYI: I was able to resolve this by writing my own promise wrapper that has no chance of recursive function calls. I'm no longer using promise-redis and the errors are gone. |
@gilly3 Can you share your code please |
Hi! Sorry for late reply. promise-redis doesn't do any recursive calls. What node_redis version is used here? Is it possible to create a reproducible example? If not, could you share parts of code that cause this error. Thanks. |
I had tried to boil this down to a small example, but was unable to do so. Any attempts at isolating the problem were unable to reproduce the error. Running all of my code, I was only ever able to reproduce this while under extreme load for several minutes. The stack trace led me to line 35, which is if (typeof args[args.length - 1] === 'function') {
// Okay. Someone supplied a callback. Most likely some internal
// node-redis call (ready probe etc.). Oh, as a result of
// supporting internal callback-style calls, one can now use
// promise-redis as a dropin replacement for node-redis.
f.apply(this, args);
} The recursion could occur if a promisified function is being passed as a parameter, thus being repromisified. My code isn't doing this, as I use promises instead of callbacks. I stopped digging and just wrote my own promisifier for the few redis calls that I need. I was using only function get(key) {
return new Promise((resolve, reject) =>
client.get(key, (err, data) => err ? reject(err) : resolve(data)));
}
function set(key, val, expire) {
return new Promise((resolve, reject) =>
client.set(key, val, "EX", expire, (err, data) => err ? reject(err) : resolve(data)));
} |
Thanks for your reply. "promisification" happens only once, when promise-redis is initialized. Each redis command is replaced with the function returned from From the stack trace it looks that it is |
While load testing my app, I am seeing
RangeError: Maximum call stack size exceeded
, with promise-redis in the stack trace. Asking here is a bit of a stab in the dark, but I thought I'd check. Here are a couple of suspicious looking stack traces:I have to process several thousand requests before I start seeing this error. It looks like the promisify function is calling itself recursively. Any idea what might be causing this?
The text was updated successfully, but these errors were encountered: