Protect dereferencing null in Node