this.getDatabase() returns null #649

bobobo1618 opened this Issue Sep 19, 2013 · 3 comments

3 participants


I've had reports of issues in my sunny plugin which outputs a trace as follows:

      files = this.getDatabase().findAllLive(query, sorting, paging);
TypeError: Cannot call method 'findAllLive' of null
    at DocPad.getFiles (/private/tmp/derptest/node_modules/docpad/out/lib/docpad.js:431:34)
    at doUpload (/private/tmp/derptest/node_modules/docpad-plugin-sunny/sunny.plugin.js:54:19)
    at null.<anonymous> (/private/tmp/derptest/node_modules/docpad-plugin-sunny/sunny.plugin.js:99:16)
    at EventEmitter.emit (events.js:98:17)
    at AuthenticatedRequest.processResults (/private/tmp/derptest/node_modules/docpad-plugin-sunny/node_modules/sunny/lib/request.js:453:10)
    at IncomingMessage.<anonymous> (/private/tmp/derptest/node_modules/docpad-plugin-sunny/node_modules/sunny/lib/request.js:427:16)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:910:16
    at process._tickDomainCallback (node.js:459:13)
An error occured within the child DocPad instance: exited with a non-zero status code

Keeping in mind that this plugin has worked fine in the past, something appears to be wrong or changed in regards to Docpad's internals.

The Docpad instance that getDatabase() is being called from is the same instance that's attached to the plugin when the constructor is called by Docpad.

The call in my code can be viewed here just in case it's something on my end.

@nfriedly nfriedly referenced this issue in bobobo1618/docpad-plugin-sunny Oct 26, 2013

Phantom config from defaults in JS file prevents deployment #10


It looks like this is because _stayAlive keeps the default value of false for the generate command in and so it destroys the database before sunny is done uploading files.

I'd imagine there's a good away around this, I know that uses it's own command, deploy-ghpages instead of piggybacking on the generate command, so that might be the best option for sunny. (It actually keeps _stayAlive set to false, it just waits until everything is done uploading before calling the next() callback.)


Looking at your writeAfter event I notice its not calling the next handler which should be fired if not null...this handler lets docpad task management continue processing..this is especially sensitive when running in generate mode because the docpad process will quit.

A very simple writeAfter would look like this

writeAfter: (opts, next) ->

@pflannery thanks for that, I added it in and the issue seems to be resolved. I would have added this if I had any idea that handler existed. Unfortunately I've never been able to find a particularly good source of documentation for the Docpad plugin system, especially given the changes that seem to happen...

@nfriedly I just switched to using a command line option. You trigger it with docpad deploy-sunny now :)

@bobobo1618 bobobo1618 closed this Oct 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment