In v6.5.1_forEachSubscriber was fully sync. In v8.0.0 that is no longer the case. Because there is an await inside the loop, there is a gap where a client can get removed while another await itemize(item) is happening.
I'm also not 100% certain, but I think the previous behavior would have been to publish the message to all clients in sync, and not wait for that action to complete, whereas now it is all done in sequence?
As for possible fixes, I'm not 100% sure which is the best, but possibly an await Promise.all(Object.keys(this._items).map((key) => itemize(this._items[key])) to fire off the publish in parallel or check that item is still there inside itemize?
I'll try to prove my theory with a unit test if there's time left in the day...
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.
I haven't been able to reproduce this exactly just yet, but there's an error happening around https://github.com/hapijs/nes/blob/v8.0.0/lib/listener.js#L610 (
await each(item.socket);
).In
v6.5.1
_forEachSubscriber
was fully sync. Inv8.0.0
that is no longer the case. Because there is anawait
inside the loop, there is a gap where a client can get removed while anotherawait itemize(item)
is happening.I'm also not 100% certain, but I think the previous behavior would have been to publish the message to all clients in sync, and not wait for that action to complete, whereas now it is all done in sequence?
As for possible fixes, I'm not 100% sure which is the best, but possibly an
await Promise.all(Object.keys(this._items).map((key) => itemize(this._items[key]))
to fire off the publish in parallel or check thatitem
is still there insideitemize
?I'll try to prove my theory with a unit test if there's time left in the day...