Skip to content

500 Accessing Fastify route for newly deployed extension #23

@cb1kenobi

Description

@cb1kenobi

Bug Summary

TypeError: Cannot read properties of undefined (reading 'length')

Reproduction Repository (if applicable)

No response

Steps to Reproduce

  1. Create extension with Fastify route
  2. Nuke ~/hdb
  3. Run: harper dev
  4. Deploy extension from local dir: harper deploy target=http://localhost:9925
  5. Access route: curl -I -X GET -H "Content-Type: application/json" -H "Authorization: Basic <token>" http://localhost:9926/myroute

Expected Behavior

It should return a 200 or 400, but definitely not a 500.

Actual Behavior

Upon deploying the extension, I see the route being registered:

<snip>
[http/1] [info]: Custom Functions starting buildServer.
[http/1] [info]: Custom Functions completed buildServer.
[http/1] [info]: Custom Functions starting buildRoutes
[http/1] [trace]: Loading fastify routes folder /Users/user/hdb/components/mytest/routes
[http/1] [debug] [jsResource]: Registered resource: /myroute
<snip>

Then curling the new route, I get the following error:

[http/1] [error]: TypeError: Cannot read properties of undefined (reading 'length')
    at next (/Users/user/projects/harperdb/node_modules/fastify/lib/hooks.js:334:32)
    at preParsingHookRunner (/Users/user/projects/harperdb/node_modules/fastify/lib/hooks.js:364:3)
    at runPreParsing (/Users/user/projects/harperdb/node_modules/fastify/lib/route.js:611:5)
    at Object.routeHandler [as handler] (/Users/user/projects/harperdb/node_modules/fastify/lib/route.js:534:7)
    at Router.callHandler (/Users/user/projects/harperdb/node_modules/find-my-way/index.js:552:14)
    at Router.lookup (/Users/user/projects/harperdb/node_modules/find-my-way/index.js:530:17)
    at Router.defaultRoute (/Users/user/projects/harperdb/node_modules/fastify/fastify.js:749:23)
    at Router._defaultRoute (/Users/user/projects/harperdb/node_modules/find-my-way/index.js:692:14)
    at Router.callHandler (/Users/user/projects/harperdb/node_modules/find-my-way/index.js:550:36)
    at Router.lookup (/Users/user/projects/harperdb/node_modules/find-my-way/index.js:530:17)

Harper is resolving [email protected] and the line that blows up is: https://github.com/fastify/fastify/blob/2d85fee1d317208e0f9c7c9103c4ebb30d7c35e6/lib/hooks.js#L334. Upon debugging, functions is definitely undefined. The functions value comes from request[kRouteContext].preParsing: https://github.com/fastify/fastify/blob/2d85fee1d317208e0f9c7c9103c4ebb30d7c35e6/lib/route.js#L611.

Here's the interesting thing, if I restart Harper, it will work as expected. In other words, something Fastify related is not being wired up after deploy, but is after restart.

Platform

Harper 4.7.3, Node.js 22.17.0, macOS 26.0.1

Console Errors

See above.

Screenshots or Videos

No response

Additional Context

No response

Are you planning to fix this issue?

No, just reporting the issue

First-time contributor support

  • I'm new to contributing and would appreciate guidance on the process
  • I'd like help understanding the project structure
  • I need assistance with setting up the development environment
  • I'm comfortable contributing, but new to this project specifically

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions