You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since you are awaiting the createConnection call before assigning connectionInstance, a race condition is possible.
For example, if you fire off multiple commands before the connection is established, they will all be given their own connection, due to the logic error above. That means the responses can come out-of-order, and the parser may resolve the wrong promise, which can result in a crash if the caller was expecting an array response, but got null, for example.
Hey there, Kane! First off, allow me to thank you for this package. It's been a great starting point for me. 🥇
Take a look at this code:
redis-on-workers/src/lib/redis-instance.ts
Lines 112 to 114 in 572ad9a
Since you are awaiting the
createConnection
call before assigningconnectionInstance
, a race condition is possible.For example, if you fire off multiple commands before the connection is established, they will all be given their own connection, due to the logic error above. That means the responses can come out-of-order, and the parser may resolve the wrong promise, which can result in a crash if the caller was expecting an array response, but got null, for example.
I already solved this in my own fork:
https://github.com/alloc/redis-on-workers/blob/f5cd056c027c3642e45cb5583252e1b1cf2d527c/src/client.ts#L103-L183
Unfortunately, I've made so many changes that I won't be able to upstream the fix to your repo. 😅
Nonetheless, I hope this helps!
Btw, your
isInitialized
property is never set to true, resulting in unnecessaryAUTH
andSELECT
commands.redis-on-workers/src/lib/redis-instance.ts
Line 23 in 572ad9a
OK, that's all for now. Peace!
The text was updated successfully, but these errors were encountered: