fastify/avvio

Do not load any more plugins with .after() when the previous errors

mcollina opened this issue · 0 comments

From Fastify https://github.com/fastify/fastify/pull/2093/files:

test('awaitable after error handling', async t => {
   const fastify = Fastify()
   let first = false
   let second = false
   let third = false

   // Note that this does not throw in case of error,
   // all errors are currently collected to ready() because it's
   // not really possible to do anything about them.
   await fastify.register(async (instance, opts, next) => {
     first = true
     throw new Error('kaboom')
   })
   t.is(first, true)

   fastify.register(async (instance, opts, next) => {
     second = true
   })

   await fastify.after()
   // TODO this is a bug, it should be false
   t.is(second, true)

   fastify.register(async (instance, opts, next) => {
     third = true
   })

   await t.rejects(fastify.ready())
   t.is(third, false)
 })

cc @davidmarkclements