Skip to content

FastifySecureSession type is not compatible with FastifyPluginCallback #272

@stampaaaron

Description

@stampaaaron

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

5.5.0

Plugin version

8.2.0

Node.js version

24.0

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

15.6

Description

When using the fastifySecureSession callback as a plugin for my nestjs fastify project, I get a typescript error:

Argument of type 'FastifySecureSession' is not assignable to parameter of type 'FastifyPluginCallback<SecureSessionPluginOptions | (SecureSessionPluginOptions & Required<Pick<SecureSessionPluginOptions, "sessionName">>)[]> | FastifyPluginAsync<...> | Promise<...> | Promise<...>'.
  Type 'FastifySecureSession' is not assignable to type 'FastifyPluginCallback<SecureSessionPluginOptions | (SecureSessionPluginOptions & Required<Pick<SecureSessionPluginOptions, "sessionName">>)[]>'.
    Types of parameters 'instance' and 'instance' are incompatible.

This is my main.ts file:

import { fastifySecureSession } from "@fastify/secure-session";
...
  await app.register(fastifySecureSession, {
    expiry: configService.get("session.expiry"),
    cookieName: configService.get("session.cookieName"),
    secret: configService.get("session.secret"),
    salt: configService.get("session.salt"),
    cookie: {
      path: "/",
      secure: true,
      sameSite: "none",
      expires: new Date(Date.now() + configService.get("session.expiry") * 1000),
    },
  });
...

I belief there is a mismatch between the fastify version 5.5 and this plugin.

Thanks for your support.

Link to code that reproduces the bug

Expected Behavior

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions