Raycaster.set reports "TypeError: Cannot read property 'x' of undefined" despite me being able to get 'x' in the previous line

I’ve actually been pulling my hair out for the past hour because I can’t get this working in general, but there’s one error in particular that is throwing me for a loop.

Here’s my code (i’ve actually pushed all my code here if you need any additional context)

export function CollisionCheck(obj) {
    // Raycaster
    const raycaster = new THREE.Raycaster(obj); 
    // For each of the objects in our scene
    for (let i = 0; i < m.objects.length; i++) {
      let sobj = m.objects[i]; // The object we're searching
      label: try {
        let objDir = sobj.position.clone().sub(obj.position).normalize(); // The direction between it and the other object.
        sobj.updateMatrixWorld(); // (I don't remember why this is here, however I think I remember it fixing something)
        console.log(obj.position.x);
        raycaster.set(obj.position, objDir); // Set up the raycaster
        let intersects = raycaster.intersectObject(sobj, true);
        if(intersects[0].distance > 0) {
            console.log(intersects[0].distance);
        }
        break label;
      } catch (ex) {console.log(ex)}
    }
}

Note how I log the variable obj.position.x and then instantly pass it to raycaster.set.

I get this flooding the console (because I’m executing this on a loop)

> 0
> collision.js:22 TypeError: Cannot read property 'x' of undefined
      at Vector3.copy (three.js:2052)
      at Group.copy (three.js:4336)
      at Ray.set (three.js:2836)
      at Raycaster.set (three.js:26162)
      at Module.CollisionCheck (collision.js:15)
      at Module.ballUpdate (ball.js:61)
      at animate (animate.js:7)

obj.position is undefined despite the fact that I can not only log it to the console, but I can literally log the exact variable that can’t be found…? I’m completely lost here, how does this even happen and how do I fix it?

…apparently putting the code in a try, catch loop (which i did because i was earlier trying to see if a gltf model would work) caused this error. Would love to know why but at least THAT problem is solved.
It’s just too bad that I can’t even console.log the intersects variable for some reason because it’s just…empty.

EDIT: Oh, the function completely stops executing at raycaster.set, that’s why. I don’t think the problem is actually fixed.

EDIT 2: Yeah, no, removing the try catch error simply makes the error not appear but doesn’t fix it.

I gave up and used cannon-es for my collision system instead. I think this will forever be the weirdest error I have ever encountered in programming.
https://pmndrs.github.io/cannon-es/