surround new Buffer(msgSize) with try catch

to prevent global error exception from happening