diff --git a/boot.js b/boot.js index f6f7c29..bac9fd7 100644 --- a/boot.js +++ b/boot.js @@ -334,7 +334,7 @@ Boot.prototype.ready = function (func) { throw new AVV_ERR_CALLBACK_NOT_FN('ready', typeof func) } this._readyQ.push(func) - this.start() + queueMicrotask(this.start.bind(this)) return } diff --git a/test/await-use.test.js b/test/await-use.test.js index b8c173d..6cd5db1 100644 --- a/test/await-use.test.js +++ b/test/await-use.test.js @@ -270,3 +270,25 @@ test('await use - mix of same and future tick callbacks', async (t) => { record += 'ready' t.equal(record, 'plugin0|plugin1|plugin2|ready') }) + +test('await use - fork the promise chain', { only: true }, (t) => { + t.plan(3) + const app = {} + boot(app, { autostart: false }) + + async function setup () { + let set = false + await app.use(async function plugin0 () { + t.pass('plugin0 init') + await sleep(500) + set = true + }) + t.equal(set, true) + } + setup() + + app.ready((err, done) => { + t.error(err) + done() + }) +}) diff --git a/test/chainable.test.js b/test/chainable.test.js index 67ecc6d..b889456 100644 --- a/test/chainable.test.js +++ b/test/chainable.test.js @@ -63,7 +63,7 @@ test('chainable automatically binded', (t) => { expose[key] = 'muahah' boot(app, { - expose: expose + expose }) t.end()