Skip to content

import/require fastify module is incredibly slow > 300 ms #5507

@imperiale-tech

Description

@imperiale-tech

Prerequisites

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

Issue

Issue description

Trying to optimize AWS Lambda init duration on Node 20 and found the issue below.

  • require('fastify') takes > 300 ms
  • const {fastify} = await import("fastify") takes > 300 ms

Operating system
macOS, Linux, Windows

Node
Tested on Node 18 and Node 20

Fastify Version
4.27.0

Steps to reproduce

console.time('FASTIFY');
const Fastify = require('fastify');
const fastify = Fastify();
console.timeEnd('FASTIFY');

or

console.time('FASTIFY');
const {fastify} = await import('fastify');
console.timeEnd('FASTIFY');

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestNew feature to be addedperformancesEverything related to performances

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions