Calling resume twice results in an assert
We're calling resume twice in create new flows and it results in the container.resume call throwing an exception. I believe the assertion should be updated to catch scenarios where this is known to be a problem, since in this case I don't think there is a user bad.
The assertion is here in container.ts // Resume processing ops assert(!this.resumedOpProcessingAfterLoad);
@vladsud - we're using this to track removing an empty try /catch on our app code.
In general, just like addref/release, unbalanced pause and resume usually indicate someone wrong with the code and could cause bad issue if it goes unchecked. (Just like double free). I'd prefer we keep this assert.
@curtisman , that makes sense and was my original suggestion, but @vladsud thinks we can instead have a more strict runtime assertion that wouldn't throw in our case. If we want to keep the current assert we'd need an API to know if a container is paused, which I don't think exists. Right now we don't know if the container is paused and I don't want to do something hacky like checking if we are in a create new flow (which is currently the only flow where we don't open paused)
I see. @vladsud, can you elaborate?
I was thinking about this kind of change (instead of assert):
// Resume processing ops
if (this.resumedOpProcessingAfterLoad) {
assert(this._deltaManager.autoReconnect);
return;
}
But now I think that this change will make it (with master and 0.16) after we enable create-new workflow that makes it much more clear separation of code paths, and thus less excuse to have a need for this patch?
since resume is only used when a container is started paused i think we should just make resume idempotent, aka after the first call just do nothing. This seems like a better option than adding more api to figure out if the container was started paused, and only resume a single time in that case. You can log a warning specifying it has already been called to help prevent copious call from clients that misunderstand the role of the resume method.
Given that there is no way to pause the container again, making resume idempotent is fine.
@vladsud we are seeing another case of 'AssertionError false == true' in the Preview app.
This happens when we call setAutoReconnect on the container when the user activity changes, i.e. they become inactive after a while and we call setAutoReconnect(false) and when they become active again we call setAutoReconnect(true). A little debugging tells me that it's the same assert that's causing it
assert(this.resumedOpProcessingAfterLoad);
I haven't been able to repro this myself but looking at some of the sessions that hit this, there doesn't seem to be a user bad. Do we think it's okay for the Preview app to add another try catch around setAutoReconnect until the right fix for the assert above comes in?
I'm going to punt it (after all discussions) :) The problem Ruchika raised was a bug on Bohemia side - resume() was not called because of some fatal error, but code assumed container is still alive and kept using it as if it's live, which caused asserts in Fluid. So asserts did their thing - they helped find a bug.
Detached create new is in 0.16.x and that should be priority to switch creation flow off current flow. With that, there might be still value in allowing resume() to be called twice, or allowing setAutoReconnect() to be called before resume(). But given the experience above (of helping find real bug), I'm inclined to keep system as is, i.e. strict in expectations on particular order events have to happen in the system.
Feedback is always welcome!