coffeescriptdocpad

DocPad plugin: odd errors when testing, hangs when including in project


I'm trying to write a DocPad plugin to import MongoDB docs into the DocPad database for use in a static website. The source code is at https://github.com/nfriedly/docpad-plugin-mongodb and it's based on https://github.com/docpad/docpad-plugin-tumblr

When I run cake test, I get this output:

cake compile
cake install
npm install (for app)
npm install (for test)
npm install (for docpad tests)
coffee compile
npm test

> docpad-plugin-mongodb@2.0.0 test c:\Users\IBM_ADMIN\docpad-plugin-mongodb
> npm run prepare_test_db && node ./out/mongodb.test.js


> docpad-plugin-mongodb@2.0.0 prepare_test_db c:\Users\IBM_ADMIN\docpad-plugin-mongodb
> mongo test/prepare_database.mongo.js

MongoDB shell version: 2.6.5
connecting to: test
connecting to: docpad_plugin_mongodb_test
mongodb
mongodb > create
notice: If everyone who saw this message donated $1/week, maintaining DocPad would become sustainable: http://docpad.org/donate
error: An error occured:
Error: Didn't place the skeleton as the desired structure already exists
  at c:\Users\IBM_ADMIN\docpad-plugin-mongodb\node_modules\docpad\out\lib\docpad.js:4107:17
  at Object.cb [as oncomplete] (fs.js:168:19)
error: To report the above error, follow the guide at: http://docpad.org/bug-report
mongodb > create OK
mongodb > load plugin mongodb
mongodb > load plugin mongodb OK
mongodb > generate
mongodb > generate > action
warning: You have multiple files being written to c:\Users\IBM_ADMIN\docpad-plugin-mongodb\test\out\testData\1.json, they are:
  - testData/1.json:c7
  - testData/1.json:c5
  Rename one of them to avoid an over-write

FAILURE: 2/3 tests ran successfully; 0 failed, 1 incomplete, 0 errors

npm ERR! Test failed.  See above for more details.
npm ERR! not ok code 0

c:\Users\IBM_ADMIN\docpad-plugin-mongodb\Cakefile:99
      throw err;
            ^
Error: Process exited with error status code
  at ChildProcess.<anonymous> (c:\Users\IBM_ADMIN\docpad-plugin-mongodb\Cakefile:88:15)
  at ChildProcess.emit (events.js:98:17)
  at maybeClose (child_process.js:756:16)
  at Process.ChildProcess._handle.onexit (child_process.js:823:5)

And, when I include the module in my project, it just hangs after this:

$ docpad run
info: Welcome to DocPad v6.69.1 (local installation: c:\Users\IBM_ADMIN\watson-developer-cloud\node_modules\docpad
notice: If everyone who saw this message donated $1/week, maintaining DocPad would become sustainable: http://docp
info: Contribute: http://docpad.org/docs/contribute
info: Plugins: eco, mongodb
info: Environment: development
info: DocPad listening to http://0.0.0.0:9778/ on directory c:\Users\IBM_ADMIN\watson-developer-cloud\out

(And if I visit localhost:9778, it just hangs and never loads a page)

It seems like it only displays logs from plugins after the first pass is complete, so I started adding throw statements to see what it was doing. It seems that it imports things from mongo successfully, and it creates the document, but when the plugin calls document.action 'load', (err) ->, that callback is never fired.

Can anyone provide some guidance on what I'm messing up and how to get things working smoothly?


Solution

  • Fixed it. The TaskGroup library (apparently) once had a .once('complete', callback) event that no longer works. Switching it to .done(callback) (and fixing a couple of other small bugs) got me working now.

    It still gives me the "Error: Didn't place the skeleton as the desired structure already exists" but the tests all pass now, so I'll call it a win.