FromAll projection construction slow down / hangs others streams

Hey,

I try to setup a new projection to let me access events by date:

function p2(n) {
return n < 10 ? ‘0’ + n : String(n);
}

fromAll()
.when({ $any: function (state, event) {
if (event.metadata == null) return ;
if (event.metadata.createdAt == null) return ;
if (typeof event.metadata.createdAt != ‘number’) return ;
const date = new Date(event.metadata.createdAt);
const YMDHm = date.getFullYear() + p2(date.getMonth() + 1) + p2(date.getDate())
+ ‘-’ + p2(date.getHours()) + p2(date.getMinutes());
linkTo(‘DateYMDHm-’ + YMDHm, event);
} });

``

but when running (not 100%) after about 2 minutes, persistents & catchup subscriptions slow down, then hangs, sockets sometime break…

if I stop the projection after a while the system began available again.

For information, projection consumes about 3k events / s

I found a hack to let the fs write at his own time, by reducing the number of events / s emitted.

It’s easy to create another bottleneck ( and fine tuning it :slight_smile:

for (let i = 0; i < 4000000; ) i += 1;

``