It can take several seconds for USB serial to connect, sometimes up to 8 seconds on Windows and typically setup will already have completed by then. If I’m trying to debug stuff in setup I usually add this at the top of setup():
// Wait for a USB serial connection for up to 15 seconds
waitFor(Serial.isConnected, 15000);
delay(1000);
Or use UART debugging (Serial1LogHandler) which logs immediately because the USB to UART converter connection stays up when the Particle device resets so logging can begin immediately.