[Coldbox 6.3.0] SessionStart, Providers, and Race Conditions - Oh My!

I’ve run into a strange problem with Coldbox’s SessionStart interception point that I believe may be a race condition error. Unfortunately, the problem is very tricky to replicate and only seems to happen 5% of the time I try it, and 50% of the time one of my clients tries it.

I’m building one of those “RememberMe” pieces of functionality that looks for a special cookie when a new session starts to see if the user should automatically be logged in. I’ve accomplished this by using an interceptor like this:

component {

    property name="rememberMeService" inject="provider:rememberMeService"; 
    property name="auth" inject="provider:authenticationService@cbauth";

     * SessionStart
     * Triggers when a new session begins
     * @sessionStruct 
    function sessionStart( sessionStruct ) {
        // if the user has a cookie on their machine called remember me
        if ( cookie.keyExists( "rememberMe" ) ) {
            try {

                var user = rememberMeService.recallMe();

                if ( user.isLoaded() ) {
                    auth.login( user );

            } catch( InvalidToken e ) {
                structDelete( cookie, "rememberMe" );



The interceptor’s sessionStart() method is pretty straightforward. I have Wirebox inject a RememberMeService with the provider: notation to ensure everything is available when this interceptor fires.

I won’t post the RememberMeService for sake of brevity, but it does have a dependency of qb (Query Builder) which is ultimately injected into a RememberMeDao via Wirebox like this:

property name="qb" inject="provider:QueryBuilder@qb";

Here’s the error I get periodically (when the application first starts up):

Weird right? I know for a fact that QueryBuilder exists, and everything works great when you hit “refresh”. The problem only occurs randomly when the application first starts up again.

The only workaround I can think of is to set my application timeout extremely high so the app never times out. However, I’d like to see if there’s a better way to solve this problem. If anyone has any tips or ideas for troubleshooting, I would love to hear it!