A little background.
I am receiving a message from my server that comes in the form of <Buffer 00 00 00>   I using the Node string_decoder function to turn this into a utf8 encoded string:
var StringDecoder = require('string_decoder').StringDecoder;
var decoder = new StringDecoder('utf8');
global.message = null;
 client.on('data', function(chunk) {
   console.log(`New Message ${decoder.write(chunk)}`);
   message = decoder.write(chunk);
 })
When running, this logs out New Message OK which is correct
In another function, I am then looping until the global variable is equal to OK, however I am running into some problems:
console.log(`Global vari ${message}`);
if(message != "OK"){
    setTimeout(check, 1000);
} else {
    return cb(true);
}
The above logs out Global vari OK however the if statement fails.  I have done a typeof check on message, and it outputs string as expected.
I'm stumped as to what is going on here, but I cannot figure it out for the life of me.
 
     
     
    