Error [FastifyError]: Plugin must be a function or a promise. Received: 'object'

· Tech · No AI

I wanted to add a test to my Fastify project, but I encountered this error:

Error [FastifyError]: Plugin must be a function or a promise. Received: 'object'

Initially, based on the error message, I confirmed that my new plugins were functioning correctly. However, I soon realized that I had placed the test file in the same directory as the routes (which are plugins!), and those routes are automatically loaded by @fastify/autoload. Moving the test file outside the directories that are automatically loaded resolved the issue.

It may not seem like a big deal, but it could potentially save both of us a few minutes in the future.

uptime
8,215 days · since 2004
posts
294 · busiest 2026 (64)
words
~143,065 · ~10 h read
topics
tech 239 · personal 55
langs
en 229 · pl 65
written
211 by hand · 83 AI-assisted
projects
3
build
ca50768 · 2026-06-30