diff --git a/lib/api.js b/lib/api.js index 07ec77d0b..7152f75b9 100644 --- a/lib/api.js +++ b/lib/api.js @@ -10,7 +10,7 @@ module.exports.create = function (Env) { nThen(function (w) { Decrees.load(Env, w(function (err) { - if (err && err.code !== "ENOENT") { + if (err) { log.error('DECREES_LOADING', { error: err.code || err, message: err.message, diff --git a/lib/decrees.js b/lib/decrees.js index c30375810..e8b83f9d8 100644 --- a/lib/decrees.js +++ b/lib/decrees.js @@ -182,9 +182,16 @@ var Schedule = require("./schedule"); var Fse = require("fs-extra"); var nThen = require("nthen"); -Decrees.load = function (Env, cb) { +Decrees.load = function (Env, _cb) { Env.scheduleDecree = Env.scheduleDecree || Schedule(); + var cb = Util.once(Util.mkAsync(function (err) { + if (err && err.code !== 'ENOENT') { + return void _cb(err); + } + _cb(); + })); + Env.scheduleDecree.blocking('', function (unblock) { var done = Util.once(Util.both(cb, unblock)); nThen(function (w) {