Why is delay(1000) breaking my serial communication? I have the following sketch...

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
}

void loop() {
  if(Serial.available() &gt; 0){
    Serial.println("Hello world from Ardunio!");
  }
}


This works great with my client code...

import SerialPort from 'serialport';
const port = new SerialPort('/dev/ttyACM0', {
  baudRate: 115200,
  autoOpen: false
})

port.open(function (err) {
  if (err) {
    return console.log('Error opening port: ', err.message)
  }

  // Because there's no callback to write, write errors will be emitted on the port:
  console.log("port opened");
  port.on('readable', function () {
    console.log('Data:', port.read())
  })
})


Now I want to slow it down so I change the sketch to...

void loop() {
  if(Serial.available() &gt; 0){
    Serial.println("Hello world from Ardunio!");
  }
  delay(10000);
}


I would expect this to delay each message by 10 seconds, however, it seems to never rerun so I do not get any messages. What am I missing? Why would delay break the loop?
NEVER use delay() in a loop - its a bad habit you get used to and then you return later on with complex code asking why nothing is happening or your webserver is dead for 10 seconds every time you receive a request.

So instead of 

void loop() {
  if(Serial.available() &gt; 0){
    Serial.println("Hello world from Ardunio!");
  }
  delay(10000);
 }


you would do

unsigned long timerStart = 0;
unsigned long myTimer = 10000;

setup(){....}

 void loop() {
  if(Serial.available() &gt; 0 ){
     if(millis() - timerStart &gt; myTimer){      // non blocking
       Serial.println("Hello world from Ardunio!");
       timerStart = millis(); // reset timer
     }    
   }
 }


What your code does at the moment is enter the IF clause if exactly in this millis the buffer is filled, then wait for ten seconds ignoring whatever you do. Next chance tohit and so on. Delay() is blocking processing => not a good thing todo in communication scenarios,