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

Unmounting middleware #4436

Closed
jmelis opened this issue Oct 20, 2020 · 1 comment
Closed

Unmounting middleware #4436

jmelis opened this issue Oct 20, 2020 · 1 comment
Labels

Comments

@jmelis
Copy link

jmelis commented Oct 20, 2020

Mounting a middleware function is documented here: https://expressjs.com/en/5x/api.html#app.use

I have a use case to unmount a middleware function: I'm exposing an express server with a dynamic collection of ApolloServers. Once the data has expired, I want to unmount it.

The current way I'm accomplishing this is by splicing app._router.stack. This feels like an unsupported method which may break in any future express version.

What is the recommended approach here? Could we request a supported way to unmount a middleware function?

@dougwilson
Copy link
Contributor

There is no safe way to unmount a middleware since it will corrupted concurrent requests routing through the system. The method is really just to swap out one router for another router. If you can provide more details on exactly what you are trying to do, we can help you with a solution.

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

No branches or pull requests

2 participants