Issue when used with fastify / vercel

Feature(s) impacted

Issues when using forestadmin with Fastify as a framework and deployed in a serverless environneme nt ( vercel )

Observed behavior

Cannot connect in development mode to my forest backend
the /forest/authentication is reached but i get a 500
If i try to reach http://localhost:3000/forest i have the “Agent is running” log

Expected behavior

Failure Logs

  InternalServerError: stream is not readable
      at readStream (/Users/seeasy/Documents/GitHub/panopli-admin-back-office/node_modules/raw-body/index.js:178:17)
      at executor (/Users/seeasy/Documents/GitHub/panopli-admin-back-office/node_modules/raw-body/index.js:113:5)
      at new Promise (<anonymous>)
      at getRawBody (/Users/seeasy/Documents/GitHub/panopli-admin-back-office/node_modules/raw-body/index.js:112:10)
      at AsyncFunction.module.exports [as json] (/Users/seeasy/Documents/GitHub/panopli-admin-back-office/node_modules/co-body/lib/json.js:39:21)
      at parseBody (/Users/seeasy/Documents/GitHub/panopli-admin-back-office/node_modules/koa-bodyparser/index.js:87:26)
      at bodyParser (/Users/seeasy/Documents/GitHub/panopli-admin-back-office/node_modules/koa-bodyparser/index.js:67:25)
      at dispatch (/Users/seeasy/Documents/GitHub/panopli-admin-back-office/node_modules/koa-compose/index.js:42:32)
      at /Users/seeasy/Documents/GitHub/panopli-admin-back-office/node_modules/@koa/router/lib/router.js:425:16
      at dispatch (/Users/seeasy/Documents/GitHub/panopli-admin-back-office/node_modules/koa-compose/index.js:42:32)

  const app = fastify({ logger: true })
  await createAgent({
    // Mandatory options (those will be provided during onboarding)
    authSecret: process.env.FOREST_AUTH_SECRET!,
    envSecret: process.env.FOREST_ENV_SECRET!,
    isProduction: process.env.NODE_ENV === 'production',
  })
  .addDataSource(createMongooseDataSource(connection, { flattenMode: 'none' }))
  .mountOnFastify(app)
  .start();
  await app.ready()
  app.server.emit('request', req, res)

Context

  • Project name: panopli-forest-back-office
  • Team name: panopli
  • Environment name: node.js
  • Agent (forest package) name & version:
    • @fastify v4.21.0
    • @forestadmin/agent": "^1.16.2,
  • Database type: …
  • Recent changes made on your end if any: …

Hi @Tom,

With version of fastify above v4.x, you will have to implement fastify/middie. Here is an example of how to do it.

Best regards,

Shohan