-
-
Notifications
You must be signed in to change notification settings - Fork 33k
Description
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.
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.