Repository: hyperjumptech/monika (ts)

Issue:
Monika exits when connected to Symon with an empty probe
**Bug Description**
Monika exits when connected to Symon with an empty probe.

**To Reproduce**
Steps to reproduce the behavior:
1. Run Symon with an empty probe
2. Connect Monika to Symon

**Expected behavior**
Monika should run and wait until it receives new configuration.

**Screenshots**
![image](https://github.com/hyperjumptech/monika/assets/15191978/0751aca0-5ce4-4570-b811-657ba86015fc)

**Desktop Details:**
 - OS: Pop!_OS
 - Version: 22.04


Pull request description:
Fix: Monika exits when connected to Symon with an empty probe
# Monika Pull Request (PR)

## What feature/issue does this PR add
Monika exits when connected to Symon with an empty probe. It will fix #1121.

## How did you implement / how did you fix it
Don't throw error when config is empty in Symon mode.

## How to test
1. Run Symon.
2. Run Monika in Symon mode.
3. Connect Monika through operator dashboard.
4. Assign to some probe.

## Video

https://github.com/hyperjumptech/monika/assets/15191978/666714a2-0c7a-4fb8-85a4-0fe61aa1f228



Patch:
diff --git a/src/components/config/index.ts b/src/components/config/index.ts
index 32a7dbc2..e22d376a 100644
--- a/src/components/config/index.ts
+++ b/src/components/config/index.ts
@@ -67,9 +67,17 @@ const defaultConfigs: Partial<Config>[] = []
 let nonDefaultConfig: Partial<Config>
 
 export const getConfig = (): Config => {
-  const { config } = getContext()
+  const { config, flags } = getContext()
 
-  if (!config) throw new Error('Configuration setup has not been run yet')
+  if (!config) {
+    if (!isSymonModeFrom(flags)) {
+      throw new Error('Configuration setup has not been run yet')
+    }
+
+    return {
+      probes: [],
+    }
+  }
 
   return config
 }


Test patch:
diff --git a/src/components/config/index.test.ts b/src/components/config/index.test.ts
index 1253227b..0ee026c7 100644
--- a/src/components/config/index.test.ts
+++ b/src/components/config/index.test.ts
@@ -29,6 +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'
 
 describe('getConfig', () => {
   afterEach(() => {
@@ -41,6 +42,19 @@ describe('getConfig', () => {
     )
   })
 
+  it('should return empty array when config is empty in Symon mode', () => {
+    // arrange
+    setContext({
+      flags: {
+        symonKey: 'bDF8j',
+        symonUrl: 'https://example.com',
+      } as MonikaFlags,
+    })
+
+    // act and assert
+    expect(getConfig()).deep.eq({ probes: [] })
+  })
+
   it('should return config', () => {
     // arrange
     const config = {