Super weird arduino EEPROM bug(?)

Hey there… I’m running into a strange behaviour with platformio, arduino and eeprom. This did not occure with the default arduino IDE so it might have something todo with platformio:

Given I have this simple sketch:

#include <Arduino.h>
#include <EEPROM.h>

void setup() {
  Serial.begin(9600);
  while (!Serial) {}

  byte version = 2;
  Serial.print("Current EEPROM value: ");
  Serial.println(EEPROM.read(1));

  EEPROM.write(1, version);
}

void loop() {
}

When you change the “version” value, this sketch will always print the “version” value even before its written to EEPROM! One would expect to see the old value printed and then it gets overwritten with the new value.

When I add an delay of 1500 before EEPROM.write it works as expected… could someone please clarify this behaviour for me? Thanks in advance