Would it be possible to have the runtime
Would it be possible to have the runtime store only the latest N WebSockets, and then GC the rest?
Req1 broadcasts to all currently connected websockets (got them via getWebSockets()), then does an await and yields event loop. Req2...ReqN create new websockets and those get used a bit, so we evict all WS prior to Req2. When Req1 is done its IO and is scheduled to run again, when it tries to refer to its array of websockets it got from getWebSockets(), something weird would happenstate that signals to the runtime that it is ok for the DO to be restarted? It would at least solve the growing number of objects problem, and might be useful for user code to be able to "clean up" if it generates a lot of in-memory stateOr even delete them when they are added, and only recreate them for the time they need to be processed?
signals to the runtime that it is ok for the DO to be restarted
Req1Req1Req2...ReqNReq2// state.evict stops further events from entering the queue, but
// does not prevent current events from being processed.
this.state.evict(() => {
// This function is run after all events have completed, but before the DO is evicted.
// Could be used for final cleanup tasks
});
return new Response(null);