fastify / fastify/restartable

Hitting `/restart` endpoint does not restart with new plugins/routes.

Open
#9 2 comments 1 reaction 0 assignees View on GitHub
documentation good first issue
Dominant language
JavaScript
Stars
109
Forks
10
PR merge metrics
No merged PRs in 30d

Description

### Prerequisites

- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the issue has not already been raised

### Issue

It says I can add dynamically routes and plugins without loosing request but something is not working for me.
I also use `autoload` so I started this server and while the server is running I added a new route in one of my plugins, then I hit the endpoint `/refresh` (which is also part of the official example) to refresh the app without downtime and get the new route working but hitting `/newroute` does not work, all I get is a `404` with `"Route GET:xx not found"` but after a shutting down the server and starting again the new route works, so maybe I'm missing something here any idea?

```ts
import { start } from '@fastify/restartable'
import autoLoad from "fastify-autoload";

async function myApp (app, opts) {
//register autload /plugins
await app.register(autoLoad, {
dir: join(__dirname, "plugins"),
maxDepth: 1,
});

app.get('/restart', async (req, reply) => {
await app.restart()
return { status: 'ok' }
})
}

const { stop, restart, listen, inject } = await start({
protocol: 'http', // or 'https'
// key: ...,
// cert: ...,
// add all other options that you would pass to fastify
host: '127.0.0.1',
port: 3000,
app: myApp
})

const { address, port } = await listen()

console.log('server listening on', address, port)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.