4-pin PC Fan PWM control and speed monitoring
The esp seems to cache its interrupts or something weird (related to disabling and enabling interrupts)

try this:

volatile int interruptCounter; //counter use to detect hall sensor in fan
int RPM;                      //variable used to store computed value of fan RPM
unsigned long previousmills;    

//NODEMCU ESP8266
#define tachInputPIN  D5             
#define pwmOutputPin D6             

#define pwmDuty 1024

#define calculationPeriod 1000 //Number of milliseconds over which to interrupts


void ICACHE_RAM_ATTR handleInterrupt() { //This is the function called by the interrupt
    interruptCounter++;

}


void setup()
{
    Serial.begin(115200);

    previousmills = 0;
    interruptCounter = 0;
    RPM = 0;

    //NODEMCU esp8266

    pinMode(pwmOutputPin, OUTPUT);
    pinMode(tachInputPIN, INPUT_PULLUP);
     analogWriteFreq(25000);  
    analogWrite(pwmOutputPin, pwmDuty);
    attachInterrupt(digitalPinToInterrupt(tachInputPIN), handleInterrupt, FALLING);

}



void loop()
{

    // NODEMCU esp8266
  //  analogWrite(pwmOutputPin, pwmDuty);

   if((millis() - previousmills) &gt; calculationPeriod) {// Process counters once every second

    previousmills = millis();
    int count = interruptCounter;
    interruptCounter = 0;
    computeFanSpeed(count);
    displayFanSpeed();



   }
yield();
}



void computeFanSpeed(int count) {
    //interruptCounter counts 2 pulses per revolution of the fan over a one second period
    RPM =  count /2 * 60 ;
}

void displayFanSpeed() {
    Serial.print(RPM, DEC);        //Prints the computed fan speed to the serial monitor
    Serial.print(" RPM\r\n");      //Prints " RPM" and a new line to the serial monitor
}


`