If you add a behavior to a mesh and then detach it, you will get an undefined exception.
TypeError: Cannot set properties of undefined (setting 'isNearGrabbable')
at PointerDragBehavior.detach (:3007/vendors-node_modules_babylonjs_core_index_js-node_modules_babylonjs_gui_index_js-node_modules-cf9bda.js:12289:43)
at Mesh.Node.dispose (:3007/vendors-node_modules_babylonjs_core_index_js-node_modules_babylonjs_gui_index_js-node_modules-cf9bda.js:241049:22)
I think the problem is here Babylon.js/pointerDragBehavior.ts at master · BabylonJS/Babylon.js · GitHub, and should maybe check if there is a node attached first?
Playground here: