Publish Property -- Strange Behavior

I found the answer to the problem.

Indeed there is a (new) default watchdog feature in the IoT cloud library which causes the reset of the arduino board if it stops communicating with the cloud for more than ~13 seconds.

The watchdog is reset when calling this function:

ArduinoCloud.update();

Thus, I've now added it to my pulse counting for loop and everything works as expected (for any n):

void onRedPulsingChange() {
  if (red_pulsing) {
    int n = pulsing_times;

    Serial.println("N:"+String(n));

    for (int j = 0; j < n; j++) {
      ArduinoCloud.update();

      for (int i = 0; i <= 180; i++) {
        MATRIX.beginDraw();
        MATRIX.fill(i, 0, 0);
        MATRIX.rect(0, 0, MATRIX.width(), MATRIX.height());
        MATRIX.endDraw();
        delay(10);
      }

      for (int i = 180; i >= 0; i--) {
        MATRIX.beginDraw();
        MATRIX.fill(i, 0, 0);
        MATRIX.rect(0, 0, MATRIX.width(), MATRIX.height());
        MATRIX.endDraw();
        delay(10);
      }
    }

    red_pulsing = false;
  }
}