New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question/Bug: Init Order #1210

lgenet opened this Issue Jan 30, 2017 · 1 comment


None yet
2 participants

lgenet commented Jan 30, 2017

This is more so a question that I am very confused by than an out-right bug/issue. The init stack is as follows.

            util.wrapTimedTask(this, this.initModules, 'initModules'),
            util.wrapTimedTask(this, this.initRequestHandler, 'initRequestHandler'),
            util.wrapTimedTask(this, this.initDBConnections, 'initDBConnections'),
            util.wrapTimedTask(this, this.initDBIndices, 'initDBIndices'),
            util.wrapTimedTask(this, this.initServerRegistration, 'initServerRegistration'),
            util.wrapTimedTask(this, this.initCommandService, 'initCommandService'),
            util.wrapTimedTask(this, this.initSiteMigration, 'initSiteMigration'),
            util.wrapTimedTask(this, this.initSessions, 'initSessions'),
            util.wrapTimedTask(this, this.initPlugins, 'initPlugins'),
            util.wrapTimedTask(this, this.initSites, 'initSites'),
            util.wrapTimedTask(this, this.initLocales, 'initLocales'),
            util.wrapTimedTask(this, this.initLibraries, 'initLibraries'),
            util.wrapTimedTask(this, this.registerMetrics, 'registerMetrics'),
            util.wrapTimedTask(this, this.initServer, 'initServer')

So, the initServer is the very last thing that runs in the stack. Inside of InitServer is when the Middleware stack is built out. This is after the plugin's get a chance to run their "onStartupWithContext" functions. In your example code, you suggest swapping out middleware in these blocks. However, I do not have access to the middleware set at this point.

Was this the intent? Based on your blog post ( with examples of using the new feature I would say that it is not. Thus I am wondering if I am missing something.

Steps to Reproduce:

Configuration Details:
Multisite, running locally.

Log Output:

PencilBlue Version: 0.8.0

Node.js Version: 4.2.2

Environment Description: OSX

@brianhyder brianhyder self-assigned this Feb 1, 2017

@brianhyder brianhyder added the bug label Feb 1, 2017

@brianhyder brianhyder added this to the 0.8.1 milestone Feb 1, 2017


This comment has been minimized.

Show comment
Hide comment

brianhyder Feb 1, 2017


@lgenet You are correct. PR coming shortly


brianhyder commented Feb 1, 2017

@lgenet You are correct. PR coming shortly

brianhyder added a commit that referenced this issue Feb 1, 2017

@brianhyder brianhyder closed this in #1212 Feb 1, 2017

@brianhyder brianhyder removed the in progress label Feb 1, 2017

brianhyder added a commit that referenced this issue Feb 1, 2017

Merge pull request #1212 from pencilblue/issue/1210
#1210 Fixes issue where middleware is not registered before plugins a…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment