Skip to content

Add support for experimental flags and run shutdown hooks in reverse order

Choose a tag to compare

@github-actions github-actions released this 14 May 09:17
· 4 commits to 8.x since this release

8.4.0 (2025-05-14)

This release introduces the concept of experimental flags at the application level. These flags will serve us in smoothly introduce breaking changes to the current version by letting early adopters use features in the current version of the framework.

Feature flags

The feature flags can be defined within the adonisrc.ts file, under the experimental block. For example:

{
  experimental: {
    shutdownInReverseOrder: true,
  }
}

If you want to author your own flags in a type-safe manner, then you can define them with the ExperimentalFlags interface using declaration merging. For example:

declare module '@adonisjs/core/types/app' {
  export interface ExperimentalFlags {
     myFlag?: boolean
  }
}

Now, the users will get type suggestions for the myFlag inside the adonisrc.ts file.

shutdownInReverseOrder

Ideally the shutdown hooks from the providers and the terminating hooks (defined as callbacks) should be executed in the reverse order so that if two providers rely on each other, then can have desired outcome in both during boot and the shutdown phase. For example:

There are two providers registered in the following order

  • AppMetricsProvider - Defines API for storing certain app metrics
  • AppLifecycleProvider - Stores the duration of the app till it was alive. This provider relies on the AppMetricsProvider and hence must be registered afterwards as well.

However, when calling the shutdown methods on providers, if we will shutdown the AppMetricsProvider first, then the AppLifecycleProvider won't be to store the app lifecycle duration. Instead, they should be shutdown in the reverse order.

Changing the order of the shutdown and the terminating hooks is a breaking change and will be the default behavior in the next major release of AdonisJS. However, for now, you can opt into it using experimental flags. Write the following block of code within the adonisrc.ts file.

{
  experimental: {
    shutdownInReverseOrder: true,
  }
}

Features

  • experimental support for running terminating and shutdown hooks in reverse order (5fa985a)
  • introduce experimental flags (48a964a)

Full Changelog: v8.3.2...v8.4.0