waitUntil(WiFi.ready); with System mode Manual

I have a question with SYSTEM_MODE(MANUAL) and waitUntil(WiFi.ready);

As I am using PhotonWdgs, I encounter the following issue.
If I loose wifi connection, code runs fine in void loop().
If I manually reset the Photon, code in loop will not run as I have waitUntil(WiFi.ready); in void setup() and it never reaches void loop().
This then triggers the Watchdog to do a system.reset

How can I continue to void loop() in this scenario?

If you manually reset the photon then setup() function will be run once.
I suggest that you put WiFi.connect(); in setup() and test it has been successful using waitFor(WiFiReady, timeout);

If there are other reasons you could WiFi.disconnect() then maybe a test for WiFi.ready() should be placed in your loop() followed by WiFi.connect(); and waitFor(WiFiReady, timeout);.

Thanks for that @armor.
I tried that out but still having the issue of staying in setup upon manual reset.

#define timeout 5000
void setup(){
 waitFor(WiFi.ready, timeout);

Is PhotonWdgs:: begin() you setting up the watchdog? 10 seconds timeout is very short for a watchdog - sometimes the WiFi.connect() can take 25 seconds! Watchdog should be set for 60 seconds IMO.

I use this declaration before Setup()

void watchdogHandler();
ApplicationWatchdog wd(watchdogPeriod, watchdogHandler);

The watchdog handler function can do a bit more than call System.reset() - i.e. you could save the reason for the watchdog being called to eeprom?

Then at the start of the loop() I call wd.checkin();

BTW - you do not need WiFi.on(); because WiFi.connect(); does this if the module is off.

Also, before calling Particle.connect(); shouldn’t you check that the device is WiFi connected with if (WiFi.ready) ? Because you have only provided snippets of your code - are you using SYSTEM_MODE(MANUAL) and SYSTEM_THREAD(ENABLED)? Without threading enabled the Particle.connect() will block the application.