Skip to content

creating multipleBindings function does not catch/handle errors #4730

@ivan-tymoshenko

Description

@ivan-tymoshenko

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

One of the multiple ways to reproduce it:

'use strict'

const http = require('http')
const fastify = require('fastify')

let counter = 0
const serverFactory = (handler, opts) => {
  if (++counter > 1) {
    throw new Error('kaboom')
  }

  const server = http.createServer((req, res) => {
    handler(req, res)
  })

  return server
}

const app = fastify({ serverFactory })

async function main () {
  try {
    await app.listen()
  } catch (err) {
    console.log(err)
  }

  await app.close()
}

process.on('uncaughtException', (err) => {
  console.log('uncaughtException', err)
})

main()

The reject is ignored here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions