Skip to content

fastify fails if serverFactory returns the same instance of http server #4725

@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

This happens because fastify uses the serverFactory to create a main server and a secondary server.

Example:

'use strict'

const { createServer } = require('http')
const fastify = require('fastify')

const server = createServer(() => {})
const app = fastify({
  serverFactory: () => server
})

app.listen({ port: 0 }, (err, address) => {
  if (err) {
    console.error(err)
    process.exit(1)
  }
  console.log(`Server listening on ${address}`)
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions