blink without delay stops after 2878 cycles?!?

Hello,
I am facing a strange behaviour that i cannot wrap my head around. this script stops after 2878 cycles.

#define debugLed 13
int pause = 1000;
int timer = 0;
int counter = 0;

void setup(){
   Serial.begin(9600);
   pinMode(debugLed, OUTPUT);
}
void loop(){
  if (millis() > pause + timer ) {
    Serial.println(counter);
    counter ++;
    digitalWrite(debugLed, !digitalRead(debugLed));
    timer = millis();
    pause = 10;//random(minWaitTime, maxWaitTime) * 1000;
  }
}

while using delay(10) works endless(?)

void loop(){
    Serial.println(counter);
    counter ++;
    digitalWrite(debugLed, !digitalRead(debugLed));
    delay(10);
}

any ideas??
btw, i am using an arduino nano

see the BlinkWithouDelay example in IDE. compare it with yours.
you have two things wrong. the data type for millis and the rollover handling .

int timer = 0;
...
...
timer = millis();

Oops

All variables involved with millis() should be declared as unsigned long.

Arithmetic involved with millis() should be subtraction, not addition.

omg. thank you so much :smiley: