node:process
The node:process module in Azion Runtime: the process object, examples of environment variables, nextTick, and process information, and the supported APIs.
The node:process module provides process, the Node.js object that holds information about the current process and controls its execution. In a function, its frequent uses are reading environment variables through process.env and scheduling work with process.nextTick(). Deployed, process.env holds the environment variables of your account, which you can also read with Azion.env.get().
In Azion Runtime, process is also a global, but the global and the default export of node:process are different objects. In the examples below, the global process.env.NODE_ENV returns production, and the same property of the imported object returns no value.
Examples
Each example is a complete function that imports from node:process. The response below each example is the one a deployed function returns.
Environment variables and nextTick
This function logs the global process.env.NODE_ENV, schedules a callback with nextTick, and returns the value in the response:
The function logs production and responds with this body:
Configuration from environment variables
This function reads four configuration values from process.env, falls back to a default for each one, and reports whether an API key is set without exposing its value:
With none of the four variables set, the function logs the warning API_KEY not configured and responds with the defaults:
Deferred execution with nextTick
This function records the order in which its code runs around two nextTick calls, waits 10 ms, and returns the order:
In a deployed function, the nextTick callbacks have not run when the function builds its response, so the order ends at End and lists neither callback:
Process information
This function reads the platform, architecture, versions, and process IDs, and returns them as formatted JSON:
The function responds with the fixed values. v8Version is undefined, so JSON.stringify leaves it out of the body:
Memory usage
This function reads process.memoryUsage() before and after it builds an array, and returns both readings and the difference:
Every field of process.memoryUsage() returns 0, so both readings and the difference are 0:
Uptime and timing
This function reads process.uptime() and process.hrtime(), then measures a 100 ms wait with process.hrtime.bigint():
Deployed, process.uptime() returns 0, process.hrtime() returns whole seconds with 0 nanoseconds, and the time measured across the 100 ms wait is 0:
Supported APIs
The table lists the status of each node:process API in Azion Runtime:
| API | Status |
|---|---|
process.env | 🟢 Supported |
process.nextTick() | 🟢 Supported |
process.platform | 🟡 Partially supported (empty string) |
process.arch | 🟡 Partially supported (empty string) |
process.version | 🟢 Supported |
process.versions | 🟡 Partially supported (node only) |
process.pid | 🟡 Partially supported (fixed value) |
process.ppid | 🟡 Partially supported (fixed value) |
process.uptime() | 🟡 Partially supported (returns 0) |
process.hrtime() | 🟡 Partially supported |
process.hrtime.bigint() | 🟡 Partially supported |
process.memoryUsage() | 🟡 Partially supported (returns 0) |
process.cwd() | 🟡 Partially supported |
process.exit() | 🟡 Partially supported |
process.on() | 🟡 Partially supported |
process.argv | 🟡 Partially supported |
process.title | 🟡 Partially supported |
process.binding() | 🔴 Not supported |
APIs marked 🟡 Partially supported have limited functionality compared to the full Node.js implementation. Their values are fixed and do not describe the machine that runs your code. process.platform, process.arch, and process.title are empty strings, process.pid is 200, and process.ppid is 100. process.version is v22.14.0, and process.versions holds only node. process.cwd() returns /, and process.argv is an empty array. Deployed, process.hrtime() and process.hrtime.bigint() return whole seconds with 0 nanoseconds.
process.exit() does not terminate the runtime process, and process.on() has limited event support. process.binding() throws Error: [unenv] process.binding is not implemented yet!. For environment configuration, use process.env, which is fully supported.