Issue #312 resolved

SessionFilter.beforeFinalize should be changed to onEndResource

Robert Brewer
created an issue

beforeFinalize is not guaranteed to run for all requests. Specifically, if the RequestHandled exception is raised, beforeFinalize will not run, and sessions will not currenlty be cleaned up. onEndResource was designed to be the guaranteed-must-run-at-end-of-request method.

Comments (6)

  1. Anonymous

    The problem is that sometimes onEndResource is called before the body is consumed (when using HTTP/1.1 and generators) ... And we want to make sure that the session data is saved (and the session locked released) *after* the body is consumed ... So how can we do that ?

  2. Anonymous

    isn't that exactly the same behavior for beforeFinalize?

    Yes it is, but in beforeFinalize we can wrap the body in another function and add some code that gets executed after the body is consumed ...

    A clean way to deal with this would be to add a hook that gets called after the body is consumed

  3. Log in to comment