-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Fastify version
4.20.0
Plugin version
No response
Node.js version
18.16.1
Operating system
Windows
Operating system version (i.e. 20.04, 11.3, 10)
11
Description
hasPlugin does not check outer scopes for registered plugins
Steps to Reproduce
import fastify from 'fastify'
import fastifyPlugin from 'fastify-plugin'
const server = fastify()
const pluginCallback = (server, options, done) => {
done()
}
const pluginName = 'awesome-plugin'
const plugin = fastifyPlugin(pluginCallback, {name: pluginName})
await server.register(plugin)
await server.register(async (server) => {
const hasPlugin = server.hasPlugin(pluginName)
console.log(hasPlugin) // prints: false
const hasPluginWorkaround =
server[Symbol.for('registered-plugin')]
.includes(pluginName)
console.log(hasPluginWorkaround) // prints: true
})
Expected Behavior
hasPlugin should be true
Reactions are currently unavailable