Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access underlying server #45

Open
2 tasks done
Pezmc opened this issue Jun 19, 2023 · 2 comments
Open
2 tasks done

How to access underlying server #45

Pezmc opened this issue Jun 19, 2023 · 2 comments

Comments

@Pezmc
Copy link

Pezmc commented Jun 19, 2023

Prerequisites

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

Issue

Previously without this module we would boot fastify as follows:

const server = await initServer()
server.listen({ port: server.config.port, host: server.config.host }

With restartable, this looks like:

const server = await restartable(initServer, { logger: true })
// How to read server.config.port?

How does one access the underlying server object to read things like .config? The wrapper seems to return an object { then: undefined } which has the apps prototype copied over.

const proxy = { then: undefined }

Currently I see:

TypeError: Cannot read properties of undefined (reading 'port')
    at app.js:55:45
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
@Pezmc
Copy link
Author

Pezmc commented Jun 19, 2023

I got to the bottom of my issue, and I believe it's a bug in this module, proposed fix in #46

@ivan-tymoshenko
Copy link
Member

ivan-tymoshenko commented Jun 23, 2023

Here is an example: https://github.com/fastify/restartable#usage

const app = await restartable(createApp, { logger: true })
const host = await app.listen({ port: 3000 })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants