First initialiazation of gancio-plugin-feeds throws exception until settings are saved AND instance is restarted

Problem

When initializing the plugin for the first time via the frontend UI, clicking Test or Save results in the following error:

2025-04-19T20:47:58.408Z info: SET plugin_Feed \[object Object\]
2025-04-19T20:47:58.424Z info: Unload plugin Feed 
2025-04-19T20:47:58.424Z error: undefined 
2025-04-19T20:47:58.447Z debug: POST /api/plugin/test/Feed

ERROR Cannot read properties of null (reading 'warning') 22:47:58

at Object._tick (gancio_plugins/gancio-plugin-feed/index.js:68:18) 
at Object.onTest (gancio_plugins/gancio-plugin-feed/index.js:63:12)
at testPlugin (server/api/controller/plugins.js:66:20)

which is related to the call of plugin.log.warning('[FEED Plugin] feed URL is required!')

67 if (!plugin.settings?.feed_URL) {
68      plugin.log.warning('[FEED Plugin] feed URL is required!')
69      clearInterval(plugin.interval)
70      return
71    }

Possible Cause?

The load() method (which sets plugin.log, plugin.settings, plugin.db, etc.) seem to only be called on instance startup.

However, onTest() and _tick() are already triggered by the frontend before load() has been called. This leads to plugin.log being null, resulting in the error above.

Workaround

  1. Activate the plugin in the UI
  2. Save the settings (ignore error)
  3. Restart the Gancio instance

After that, the plugin works correctly.

Suggested Fix

The error should be suppressed gracefully during first-time configuration. If a restart is required for the plugin to function correctly, users should be clearly informed after activation that a restart is necessary before testing or using the plugin. Optionally, the input fields in the UI could be disabled (grayed out) until the restart has occurred to avoid confusion — unless they are needed to persist values for initialization on startup.

If the goal is to allow full functionality without requiring a restart, then an appropriate initialization routine must be implemented to ensure all required internal fields (like logging and settings) are available before plugin methods are triggered.

Edited by MarekBenjamin