Skip to content

Allow to persist the NODE_COMPILE_CACHE programmatically #54770

@javivelasco

Description

@javivelasco

What is the problem this feature will solve?

The implementation for NODE_COMPILE_CACHE is a long-awaited feature, and we are super happy to have it in Node.js 22. However, at the time of writing this, and unless I missed it somewhere, the cache can only be persisted on process shutdown.

This is an issue in serverless environments where a Node.js function starts in a VM and then gets paused/resumed on subsequent invocations until, at some point, it gets shut down. In this use case, the file system is ephemeral, and we can't easily hook into the process shutdown to persist the cache.

What is the feature you are proposing to solve the problem?

We propose having an API exposed in the module API to either:

  • Get a blob with the contents of the cache without having to persist it to disk.
  • Write the cache to disk.

cc @joyeecheung @QuiiBz

What alternatives have you considered?

We considered shutting down the process and resuming it within the VM to get the cache, but that leaves us with a cold new process. Although it would pick up the cache, it would still perform worse than a warm one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions