Repository: hyperjumptech/monika
Pull request #1150 (2023-10-24 09:14:17)

Feat: Make Retry Configurable
# Monika Pull Request (PR)

## What feature/issue does this PR add
Make retry mechanism configurable.

## How did you implement / how did you fix it
Add `retryInitialDelayMs` and retryMaxDelayMs flag.
Add a default value to the flag.
Use the flag value to the retry configuration.
Move all the flag related function into one file, because currently it is separated into multiple files.

## How to test
1. Run `npm start` to use default retry config.
2. Run `npm start -- --retryInitialDelayMs 5000` to change initial delay.
3. Run `npm start -- --retryInitialDelayMs 128 --retryMaxDelayMs 300` to change retry maximum delay.

## Video

https://github.com/hyperjumptech/monika/assets/15191978/55020b18-e2a5-4608-9f99-3b11a0ffdbde



codecov[bot]: ## [Codecov](https://app.codecov.io/gh/hyperjumptech/monika/pull/1150?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech) Report
> Merging [#1150](https://app.codecov.io/gh/hyperjumptech/monika/pull/1150?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech) (816390b) into [main](https://app.codecov.io/gh/hyperjumptech/monika/commit/91517c1c325fda6f92033fb1b0cc0a4266c07c6c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech) (91517c1) will **increase** coverage by `0.32%`.
> Report is 1 commits behind head on main.
> The diff coverage is `90.90%`.

> :exclamation: Current head 816390b differs from pull request most recent head 3937a29. Consider uploading reports for the commit 3937a29 to get more accurate results

```diff
@@            Coverage Diff             @@
##             main    #1150      +/-   ##
==========================================
+ Coverage   59.25%   59.58%   +0.32%     
==========================================
  Files         111      111              
  Lines        3240     3241       +1     
  Branches      641      641              
==========================================
+ Hits         1920     1931      +11     
- Misses       1026     1035       +9     
+ Partials      294      275      -19     
```


| [Files](https://app.codecov.io/gh/hyperjumptech/monika/pull/1150?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech) | Coverage Δ | |
|---|---|---|
| [src/commands/monika.ts](https://app.codecov.io/gh/hyperjumptech/monika/pull/1150?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbW1hbmRzL21vbmlrYS50cw==) | `48.30% <100.00%> (-0.44%)` | :arrow_down: |
| [src/components/config/create-config.ts](https://app.codecov.io/gh/hyperjumptech/monika/pull/1150?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvY29uZmlnL2NyZWF0ZS1jb25maWcudHM=) | `30.76% <ø> (ø)` | |
| [src/components/config/get.ts](https://app.codecov.io/gh/hyperjumptech/monika/pull/1150?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvY29uZmlnL2dldC50cw==) | `75.00% <ø> (ø)` | |
| [src/components/config/index.ts](https://app.codecov.io/gh/hyperjumptech/monika/pull/1150?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvY29uZmlnL2luZGV4LnRz) | `69.67% <100.00%> (ø)` | |
| [src/components/config/parse-sitemap.ts](https://app.codecov.io/gh/hyperjumptech/monika/pull/1150?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvY29uZmlnL3BhcnNlLXNpdGVtYXAudHM=) | `75.75% <100.00%> (ø)` | |
| [src/components/config/parse-text.ts](https://app.codecov.io/gh/hyperjumptech/monika/pull/1150?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvY29uZmlnL3BhcnNlLXRleHQudHM=) | `81.81% <100.00%> (ø)` | |
| [src/components/config/parse.ts](https://app.codecov.io/gh/hyperjumptech/monika/pull/1150?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvY29uZmlnL3BhcnNlLnRz) | `59.52% <ø> (ø)` | |
| [src/components/logger/startup-message.ts](https://app.codecov.io/gh/hyperjumptech/monika/pull/1150?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvbG9nZ2VyL3N0YXJ0dXAtbWVzc2FnZS50cw==) | `94.44% <ø> (ø)` | |
| [...c/components/notification/schedule-notification.ts](https://app.codecov.io/gh/hyperjumptech/monika/pull/1150?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvbm90aWZpY2F0aW9uL3NjaGVkdWxlLW5vdGlmaWNhdGlvbi50cw==) | `100.00% <ø> (ø)` | |
| [src/components/probe/index.ts](https://app.codecov.io/gh/hyperjumptech/monika/pull/1150?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvcHJvYmUvaW5kZXgudHM=) | `80.64% <ø> (ø)` | |
| ... and [6 more](https://app.codecov.io/gh/hyperjumptech/monika/pull/1150?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech) | |

... and [4 files with indirect coverage changes](https://app.codecov.io/gh/hyperjumptech/monika/pull/1150/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech)

:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech)


Patch:
diff --git a/docs/src/pages/guides/cli-options.md b/docs/src/pages/guides/cli-options.md
index b7bc0933..6be35eb4 100644
--- a/docs/src/pages/guides/cli-options.md
+++ b/docs/src/pages/guides/cli-options.md
@@ -267,12 +267,20 @@ You can combine this flag with the `--id` flag to repeat custom sequences.
 monika -r 3 -i 1,3,1
 ```
 
-## Maximum start delay
+## Retry Initial Delay
 
-When there are many probes, Monika by default will not start the probing all at the same time. It will delay the start of the probing by dividing the value of `--max-start-delay` flag with the number of the probes plus a random value between 0 to 1 seconds. This is to prevent connection timeout due to probing too many probes at the same time. The default value of `--max-start-delay` is 60000 (milliseconds) which corresponds to 1 minutes.
+If Monika failed to probe, it will retry the request with and increase the interval exponentially. To set the first delay, you can use the `--retryInitialDelayMs` flag. Default to 128ms.
 
-```bash
-monika --max-start-delay 300000 # this will set max-start-delay to 5 minutes.
+```sh
+monika --retryInitialDelayMs 128
+```
+
+## Retry Maximum Delay
+
+You can also set the maximum of delay by using the `--retryMaxDelayMs` flag. Default to 30,000ms or 30 seconds.
+
+```sh
+monika --retryMaxDelayMs 30000
 ```
 
 ## Follow Redirects
diff --git a/src/commands/monika.ts b/src/commands/monika.ts
index 4681c9aa..574cd32a 100644
--- a/src/commands/monika.ts
+++ b/src/commands/monika.ts
@@ -35,14 +35,18 @@ import { sendMonikaStartMessage } from '../components/notification/start-message
 import { scheduleSummaryNotification } from '../components/notification/schedule-notification'
 import { setContext } from '../context'
 import events from '../events'
-import { symonAPIVersion } from '../flag'
+import {
+  type MonikaFlags,
+  monikaFlagsDefaultValue,
+  retryInitialDelayMs,
+  retryMaxDelayMs,
+  symonAPIVersion,
+} from '../flag'
 import type { Config } from '../interfaces/config'
 import type { Probe } from '../interfaces/probe'
 import { printSummary, savePidFile } from '../jobs/summary-notification'
 import initLoaders from '../loaders'
 import { sanitizeProbe, startProbing } from '../looper'
-import { monikaFlagsDefaultValue } from '../context/monika-flags'
-import type { MonikaFlags } from '../context/monika-flags'
 import SymonClient from '../symon'
 import { getEventEmitter } from '../utils/events'
 import { log } from '../utils/pino'
@@ -243,18 +247,16 @@ export default class Monika extends Command {
         'Enable auto-update for Monika. Available options: major, minor, patch. This will make Monika terminate itself on successful update but does not restart',
     }),
 
-    'max-start-delay': Flags.integer({
-      default: monikaFlagsDefaultValue['max-start-delay'],
-      description:
-        'The maximum delay (in milliseconds) to start probing when there are many probes. When this is set to value greater than zero, all of the probes will start at slightly different time but within the value set here.',
-    }),
-
     'follow-redirects': Flags.integer({
       default: monikaFlagsDefaultValue['follow-redirects'],
       description:
         'Monika will follow redirects as many times as the specified value here. By default, Monika will follow redirects once. To disable redirects following, set the value to zero.',
     }),
 
+    retryInitialDelayMs,
+
+    retryMaxDelayMs,
+
     'symon-api-version': symonAPIVersion(),
   }
 
diff --git a/src/components/config/create-config.ts b/src/components/config/create-config.ts
index 22b23143..aa9b506d 100644
--- a/src/components/config/create-config.ts
+++ b/src/components/config/create-config.ts
@@ -23,7 +23,7 @@
  **********************************************************************************/
 
 import fs from 'fs'
-import type { MonikaFlags } from '../../context/monika-flags'
+import type { MonikaFlags } from '../../flag'
 import { log } from '../../utils/pino'
 import { sendHttpRequest } from '../../utils/http'
 
diff --git a/src/components/config/get.ts b/src/components/config/get.ts
index 0ba8f97d..4f80f7e5 100644
--- a/src/components/config/get.ts
+++ b/src/components/config/get.ts
@@ -22,7 +22,7 @@
  * SOFTWARE.                                                                      *
  **********************************************************************************/
 
-import type { MonikaFlags } from '../../context/monika-flags'
+import type { MonikaFlags } from '../../flag'
 import type { Config } from '../../interfaces/config'
 import { log } from '../../utils/pino'
 import { parseConfig } from './parse'
diff --git a/src/components/config/index.ts b/src/components/config/index.ts
index f6c4485a..f601b76a 100644
--- a/src/components/config/index.ts
+++ b/src/components/config/index.ts
@@ -30,8 +30,8 @@ import isUrl from 'is-url'
 import events from '../../events'
 import type { Config } from '../../interfaces/config'
 import { getContext, setContext } from '../../context'
-import { monikaFlagsDefaultValue } from '../../context/monika-flags'
-import type { MonikaFlags } from '../../context/monika-flags'
+import { monikaFlagsDefaultValue } from '../../flag'
+import type { MonikaFlags } from '../../flag'
 import { getEventEmitter } from '../../utils/events'
 import { md5Hash } from '../../utils/hash'
 import { open } from '../../utils/open-website'
diff --git a/src/components/config/parse-sitemap.ts b/src/components/config/parse-sitemap.ts
index 13a03331..026ee8d8 100644
--- a/src/components/config/parse-sitemap.ts
+++ b/src/components/config/parse-sitemap.ts
@@ -24,8 +24,8 @@
 
 import type { Config } from '../../interfaces/config'
 import { XMLParser } from 'fast-xml-parser'
-import { monikaFlagsDefaultValue } from '../../context/monika-flags'
-import type { MonikaFlags } from '../../context/monika-flags'
+import { monikaFlagsDefaultValue } from '../../flag'
+import type { MonikaFlags } from '../../flag'
 import type { Probe, ProbeAlert } from '../../interfaces/probe'
 
 const generateProbesFromXml = (config: any) => {
diff --git a/src/components/config/parse-text.ts b/src/components/config/parse-text.ts
index 14cc0ace..cb14f33c 100644
--- a/src/components/config/parse-text.ts
+++ b/src/components/config/parse-text.ts
@@ -47,7 +47,7 @@
  **********************************************************************************/
 
 import type { Config } from '../../interfaces/config'
-import { monikaFlagsDefaultValue } from '../../context/monika-flags'
+import { monikaFlagsDefaultValue } from '../../flag'
 import type { Probe, ProbeAlert } from '../../interfaces/probe'
 import { isValidURL } from '../../utils/is-valid-url'
 
diff --git a/src/components/config/parse.ts b/src/components/config/parse.ts
index 17f59bd4..83ba714b 100644
--- a/src/components/config/parse.ts
+++ b/src/components/config/parse.ts
@@ -24,7 +24,7 @@
 
 import { Config } from '../../interfaces/config'
 import { readFileSync } from 'fs'
-import type { MonikaFlags } from '../../context/monika-flags'
+import type { MonikaFlags } from '../../flag'
 import { parseConfigFromPostman } from './parse-postman'
 import { parseConfigFromSitemap } from './parse-sitemap'
 import { parseConfigFromText } from './parse-text'
diff --git a/src/components/logger/startup-message.ts b/src/components/logger/startup-message.ts
index be667355..61f3cfdf 100644
--- a/src/components/logger/startup-message.ts
+++ b/src/components/logger/startup-message.ts
@@ -26,7 +26,7 @@ import path from 'path'
 import isUrl from 'is-url'
 import boxen from 'boxen'
 import chalk from 'chalk'
-import type { MonikaFlags } from '../../context/monika-flags'
+import type { MonikaFlags } from '../../flag'
 import type { Config } from '../../interfaces/config'
 import type { Notification } from '@hyperjumptech/monika-notification'
 import { channels } from '@hyperjumptech/monika-notification'
diff --git a/src/components/notification/schedule-notification.ts b/src/components/notification/schedule-notification.ts
index b28d62dc..479a8524 100644
--- a/src/components/notification/schedule-notification.ts
+++ b/src/components/notification/schedule-notification.ts
@@ -1,6 +1,6 @@
 import cron from 'node-cron'
 import type { ScheduledTask } from 'node-cron'
-import type { MonikaFlags } from '../../context/monika-flags'
+import type { MonikaFlags } from '../../flag'
 import type { Config } from '../../interfaces/config'
 import { getSummaryAndSendNotif } from '../../jobs/summary-notification'
 import { isSymonModeFrom } from '../config'
diff --git a/src/components/probe/index.ts b/src/components/probe/index.ts
index ddb7d891..205c1bbe 100644
--- a/src/components/probe/index.ts
+++ b/src/components/probe/index.ts
@@ -71,8 +71,8 @@ export async function doProbe({
 
     await retry(handleAll, {
       backoff: new ExponentialBackoff({
-        initialDelay: 30_000,
-        maxDelay: 300_000,
+        initialDelay: getContext().flags.retryInitialDelayMs,
+        maxDelay: getContext().flags.retryMaxDelayMs,
       }),
     }).execute(() =>
       Promise.all(
diff --git a/src/context/index.ts b/src/context/index.ts
index a12b78cd..d0964b6d 100644
--- a/src/context/index.ts
+++ b/src/context/index.ts
@@ -24,8 +24,8 @@
 
 import type { Config } from '../interfaces/config'
 import type { ProbeAlert } from '../interfaces/probe'
-import { monikaFlagsDefaultValue } from './monika-flags'
-import type { MonikaFlags } from './monika-flags'
+
+import { type MonikaFlags, monikaFlagsDefaultValue } from '../flag'
 
 export type Incident = {
   probeID: string
@@ -47,24 +47,7 @@ type NewContext = Partial<Context>
 const initialContext: Context = {
   userAgent: '',
   incidents: [],
-  flags: {
-    config: monikaFlagsDefaultValue.config,
-    'config-filename': monikaFlagsDefaultValue['config-filename'],
-    'config-interval': monikaFlagsDefaultValue['config-interval'],
-    'create-config': false,
-    flush: false,
-    'follow-redirects': monikaFlagsDefaultValue['follow-redirects'],
-    force: false,
-    'keep-verbose-logs': false,
-    logs: false,
-    'max-start-delay': monikaFlagsDefaultValue['max-start-delay'],
-    'one-probe': false,
-    repeat: 0,
-    stun: monikaFlagsDefaultValue.stun,
-    summary: false,
-    verbose: false,
-    version: undefined,
-  },
+  flags: monikaFlagsDefaultValue,
 }
 
 let context: Context = initialContext
diff --git a/src/context/monika-flags.ts b/src/context/monika-flags.ts
index 8ca7a1c9..b3926281 100644
--- a/src/context/monika-flags.ts
+++ b/src/context/monika-flags.ts
@@ -24,66 +24,8 @@
 
 import fs from 'fs'
 import path from 'path'
-import { SYMON_API_VERSION } from '../flag'
 
-export type MonikaFlags = {
-  'auto-update'?: string
-  config: string[]
-  'config-filename': string
-  'config-interval': number
-  'create-config': boolean
-  flush: boolean
-  'follow-redirects': number
-  force: boolean
-  har?: string
-  id?: string
-  insomnia?: string
-  json?: boolean
-  'keep-verbose-logs': boolean
-  logs: boolean
-  'max-start-delay': number
-  'one-probe': boolean
-  output?: string
-  postman?: string
-  prometheus?: number
-  repeat: number
-  sitemap?: string
-  'status-notification'?: string
-  stun: number
-  summary: boolean
-  symonKey?: string
-  symonLocationId?: string
-  symonMonikaId?: string
-  symonReportInterval?: number
-  symonReportLimit?: number
-  symonUrl?: string
-  'symon-api-version'?: SYMON_API_VERSION
-  text?: string
-  verbose: boolean
-  version: void
-}
-
-const seconds = 1000
-const minutes = 60 * seconds
-export const monikaFlagsDefaultValue: Pick<
-  MonikaFlags,
-  | 'config'
-  | 'config-filename'
-  | 'config-interval'
-  | 'follow-redirects'
-  | 'max-start-delay'
-  | 'stun'
-> = {
-  config: getDefaultConfig(),
-  'config-filename': 'monika.yml',
-  'config-interval': 900,
-  'follow-redirects': 21, // axios default https://github.com/axios/axios
-  'max-start-delay': 1 * Number(minutes),
-  // default is 20s interval lookup
-  stun: 20,
-}
-
-function getDefaultConfig(): Array<string> {
+export function getDefaultConfig(): Array<string> {
   const filesArray = fs.readdirSync(path.dirname('../'))
   const monikaDotJsonFile = filesArray.find((x) => x === 'monika.json')
   const monikaDotYamlFile = filesArray.find(
diff --git a/src/flag.ts b/src/flag.ts
index 1310e7f4..40120a45 100644
--- a/src/flag.ts
+++ b/src/flag.ts
@@ -24,14 +24,86 @@
 
 import { Flags } from '@oclif/core'
 
+import { getDefaultConfig } from './context/monika-flags'
+
 export enum SYMON_API_VERSION {
   'v1' = 'v1',
   'v2' = 'v2',
 }
 
+export type MonikaFlags = {
+  'auto-update'?: string
+  config: string[]
+  'config-filename': string
+  'config-interval': number
+  'create-config': boolean
+  flush: boolean
+  'follow-redirects': number
+  force: boolean
+  har?: string
+  id?: string
+  insomnia?: string
+  json?: boolean
+  'keep-verbose-logs': boolean
+  logs: boolean
+  'one-probe': boolean
+  output?: string
+  postman?: string
+  prometheus?: number
+  repeat: number
+  retryInitialDelayMs: number
+  retryMaxDelayMs: number
+  sitemap?: string
+  'status-notification'?: string
+  stun: number
+  summary: boolean
+  'symon-api-version'?: SYMON_API_VERSION
+  symonKey?: string
+  symonLocationId?: string
+  symonMonikaId?: string
+  symonReportInterval?: number
+  symonReportLimit?: number
+  symonUrl?: string
+  text?: string
+  verbose: boolean
+  version: void
+}
+
+export const monikaFlagsDefaultValue: MonikaFlags = {
+  config: getDefaultConfig(),
+  'config-filename': 'monika.yml',
+  'config-interval': 900,
+  'create-config': false,
+  flush: false,
+  'follow-redirects': 21,
+  force: false,
+  'keep-verbose-logs': false,
+  logs: false,
+  'one-probe': false,
+  repeat: 0,
+  retryInitialDelayMs: 128,
+  retryMaxDelayMs: 30_000,
+  // default is 20s interval lookup
+  stun: 20,
+  summary: false,
+  verbose: false,
+  version: undefined,
+}
+
 export const symonAPIVersion = Flags.custom<SYMON_API_VERSION>({
   default: SYMON_API_VERSION.v1,
-  options: [SYMON_API_VERSION.v1, SYMON_API_VERSION.v2],
   description:
     'Symon API version to use. Available options: v1, v2. Default: v1',
+  options: [SYMON_API_VERSION.v1, SYMON_API_VERSION.v2],
+})
+
+export const retryInitialDelayMs = Flags.integer({
+  default: 128,
+  description:
+    'The initial, first delay of the backoff retry when probe request is failed, in milliseconds. Defaults to 128ms.',
+})
+
+export const retryMaxDelayMs = Flags.integer({
+  default: 30_000,
+  description: 'Maximum backoff retry delay, in milliseconds. Defaults to 30s.',
 })
diff --git a/src/loaders/index.ts b/src/loaders/index.ts
index 7e9e30de..a5fa388c 100644
--- a/src/loaders/index.ts
+++ b/src/loaders/index.ts
@@ -26,7 +26,7 @@ import type { Config as IConfig } from '@oclif/core'
 import { isSymonModeFrom, setupConfig } from '../components/config'
 import { setContext } from '../context'
 import events from '../events'
-import type { MonikaFlags } from '../context/monika-flags'
+import type { MonikaFlags } from '../flag'
 import { tlsChecker } from '../jobs/tls-check'
 import type { Probe } from '../interfaces/probe'
 import { loopCheckSTUNServer } from '../looper'
diff --git a/src/symon/index.ts b/src/symon/index.ts
index 2059511f..7a985cd1 100644
--- a/src/symon/index.ts
+++ b/src/symon/index.ts
@@ -34,7 +34,7 @@ import path from 'path'
 import { updateConfig } from '../components/config'
 import { getOSName } from '../components/notification/alert-message'
 import { getContext } from '../context'
-import type { MonikaFlags } from '../context/monika-flags'
+import type { MonikaFlags } from '../flag'
 import events from '../events'
 import { Config } from '../interfaces/config'
 import { Probe } from '../interfaces/probe'


Test patch:
diff --git a/src/components/config/__tests__/create-config.test.ts b/src/components/config/__tests__/create-config.test.ts
index 92a6c0ad..9f17e2aa 100644
--- a/src/components/config/__tests__/create-config.test.ts
+++ b/src/components/config/__tests__/create-config.test.ts
@@ -26,7 +26,7 @@ import { expect } from 'chai'
 import fs from 'fs'
 import _ from 'lodash'
 
-import type { MonikaFlags } from '../../../context/monika-flags'
+import type { MonikaFlags } from '../../../flag'
 import { createConfig } from '../'
 
 beforeEach(() => {
diff --git a/src/components/config/index.test.ts b/src/components/config/index.test.ts
index 603d0c77..7b2b2ead 100644
--- a/src/components/config/index.test.ts
+++ b/src/components/config/index.test.ts
@@ -29,7 +29,7 @@ import type { Config } from '../../interfaces/config'
 import events from '../../events'
 import { md5Hash } from '../../utils/hash'
 import { getEventEmitter } from '../../utils/events'
-import type { MonikaFlags } from '../../context/monika-flags'
+import type { MonikaFlags } from '../../flag'
 
 describe('getConfig', () => {
   afterEach(() => {
diff --git a/src/components/probe/index.test.ts b/src/components/probe/index.test.ts
index 9bdb0728..0e9ada60 100644
--- a/src/components/probe/index.test.ts
+++ b/src/components/probe/index.test.ts
@@ -38,7 +38,7 @@ import { initializeProbeStates } from '../../utils/probe-state'
 import type { Probe } from '../../interfaces/probe'
 import { afterEach, beforeEach } from 'mocha'
 import { getContext, resetContext, setContext } from '../../context'
-import type { MonikaFlags } from '../../context/monika-flags'
+import type { MonikaFlags } from '../../flag'
 import { FAILED_REQUEST_ASSERTION } from '../../looper'
 
 let urlRequestTotal = 0
diff --git a/src/components/probe/prober/http/request.test.ts b/src/components/probe/prober/http/request.test.ts
index fdf05698..ae935a32 100644
--- a/src/components/probe/prober/http/request.test.ts
+++ b/src/components/probe/prober/http/request.test.ts
@@ -28,7 +28,7 @@ import { setupServer } from 'msw/node'
 import { RequestInterceptor } from 'node-request-interceptor'
 import withDefaultInterceptors from 'node-request-interceptor/lib/presets/default'
 import { setContext } from '../../../../context'
-import type { MonikaFlags } from '../../../../context/monika-flags'
+import type { MonikaFlags } from '../../../../flag'
 import type {
   ProbeRequestResponse,
   RequestConfig,