You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the bug has not already been reported
Fastify version
4.4.0
Plugin version
6.5.0
Node.js version
16.14.2
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
12.5
Description
I need to serve static files from several sibling directories, every directory on different route.
Wrapped this plugin in a plugin with prefix which seems valid to me.
When path is correct everything works ok.
Cannot use 404 handler properly, and that makes everything confusing and pretty unreliable.
If path is not correct not found handler is not called and following error is occurred:
TypeError: Cannot read properties of undefined (reading 'length') at next (fastify-static-not-found-bug/node_modules/fastify/lib/hooks.js:212:25) at onSendHookRunner (fastify-static-not-found-bug/node_modules/fastify/lib/hooks.js:241:3) at preserializeHook (fastify-static-not-found-bug/node_modules/fastify/lib/reply.js:454:5) at _Reply.Reply.send (fastify-static-not-found-bug/node_modules/fastify/lib/reply.js:182:7) at fastify-static-not-found-bug/node_modules/fastify/lib/wrapThenable.js:25:15
Not sure if this is related with encapsulation in some way, but I think that according to the docs everything is valid.
Calling of proper not found handler defined in specific plugin context.
The text was updated successfully, but these errors were encountered:
vlatkoodrljin
changed the title
Not found handler bug when used as plugin with prefix
Not found handler not called when used as plugin with prefix
Aug 17, 2022
Prerequisites
Fastify version
4.4.0
Plugin version
6.5.0
Node.js version
16.14.2
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
12.5
Description
I need to serve static files from several sibling directories, every directory on different route.
Wrapped this plugin in a plugin with prefix which seems valid to me.
When path is correct everything works ok.
Cannot use 404 handler properly, and that makes everything confusing and pretty unreliable.
If path is not correct not found handler is not called and following error is occurred:
TypeError: Cannot read properties of undefined (reading 'length') at next (fastify-static-not-found-bug/node_modules/fastify/lib/hooks.js:212:25) at onSendHookRunner (fastify-static-not-found-bug/node_modules/fastify/lib/hooks.js:241:3) at preserializeHook (fastify-static-not-found-bug/node_modules/fastify/lib/reply.js:454:5) at _Reply.Reply.send (fastify-static-not-found-bug/node_modules/fastify/lib/reply.js:182:7) at fastify-static-not-found-bug/node_modules/fastify/lib/wrapThenable.js:25:15
Not sure if this is related with encapsulation in some way, but I think that according to the docs everything is valid.
Steps to Reproduce
https://github.com/vlatkoodrljin/fastify-static-not-found-bug
yarn install
node index
Visit for example: http://localhost:3000/public/js/temp2.js and observe returned error
Expected Behavior
Calling of proper not found handler defined in specific plugin context.
The text was updated successfully, but these errors were encountered: