Avvio is a robust, reentrant, and graph-based library designed for managing the asynchronous bootstrapping of Node.js applications. It simplifies complex application startup sequences by handling plugin loading order, inter-plugin dependencies, and comprehensive error management automatically. Unlike simpler sequential loaders, Avvio allows plugins to register other plugins, ensuring correct execution flow within deeply nested structures. The current stable version is 9.2.0, with a release cadence of minor and patch updates every few weeks or months, often driven by dependency updates or minor feature enhancements. Its key differentiator is its emphasis on reentrancy and a dependency graph, which guarantees that even deeply nested plugins are initialized in the precise order required, coupled with sophisticated error handling capabilities.
npm install avvioVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to initialize Avvio, register a series of asynchronous plugins including nested ones and those leveraging async/await syntax, and then wait for the application to be fully booted before gracefully closing it.
Upgrade your Node.js runtime to a currently supported Long Term Support (LTS) version, typically Node.js 18 or newer, to be compatible with Avvio v9.x and benefit from its latest features and security patches.
Ensure all plugins complete their asynchronous operations promptly. For long-running initialization tasks, consider increasing the `timeout` option during Avvio initialization (e.g., `avvio({}, { timeout: 10000 })`) or refactor plugins to optimize their initialization speed.Standardize on either callback-based plugins (always invoke `cb()`) or Promise-based plugins (always return a Promise, implicitly or explicitly). If an `async` function is used, ensure it *only* returns a Promise and does not also call `cb()`.
For Avvio versions older than 9.1.0, always call the callback (`cb()`) even for synchronous plugins. For Avvio v9.1.0 and newer, synchronous plugins can simply omit the callback call if they perform no asynchronous operations.
Increase the `timeout` option when initializing Avvio (e.g., `avvio({}, { timeout: 15000 })`) or, preferably, debug the plugin to identify and resolve performance bottlenecks that are causing the delay.Replace `app.register(myPlugin, options)` with `app.use(myPlugin, options)` as Avvio's plugin registration method is named `use`.
Ensure correct ESM import syntax: `import avvio from 'avvio'; const app = avvio();`. If using CommonJS, ensure `const avvio = require('avvio'); const app = avvio();`.Examine the `after` hook function to identify any long-running or blocking operations. Either optimize the hook's performance, or increase the global `timeout` option if the delay is expected and acceptable.
No dependency data recorded yet.