How to calculate vertex normals of custom cylinder

Yeah, my mistake. Computation of normals seems work even with NaNs.
And those weird “stripes”-like shades on your custom cylinder are caused by shared vertices for side faces and for top or bottom faces.
In CylinderGeometry, top and bottom caps have their own set of vertices.