Skip to content

Cannot read properties of undefined (reading "x") #280

Open
@codingMASTER398

Description

I'm currently developing a game that uses p5play, and thus planck.js under the hood.

There's been a ton of circumstances where I've come across the same error- Cannot read properties of undefined (reading "x") in planck.js, scattered across a ton of functions- from Distance, to vector transforms, all stemming from the step call.

From my hours of debugging these countless errors, I have never been able to pin it down to one function call, one variable that was NaN, or anything of the sorts. It's seemingly completely random, and drives me completely insane.

This is a plea to have an option to attempt to catch these kinds of errors- when there's something undefined, NaN or unusable, I expect the library to be able to tell me. Something similar to p5's friendly error system, non-existent in the minified version, perhaps, or handling these sorts of issues in a way where my entire program doesn't crash, and the offender is just excluded from the physics calculation.

All of these errors seem to look the same:

TypeError: Cannot read properties of undefined (reading 'x')
    at transformVec2 (eval at worldInit (/home/ubuntu/me-when/server/index.js:417:16), <anonymous>:2408:28) [planck line 2408]
    at Distance (eval at worldInit (/home/ubuntu/me-when/server/index.js:417:16), <anonymous>:4590:13) [planck line 4590]
    at TimeOfImpact (eval at worldInit (/home/ubuntu/me-when/server/index.js:417:16), <anonymous>:5368:13)  [planck line etc, etc]
    at Solver.solveWorldTOI (eval at worldInit (/home/ubuntu/me-when/server/index.js:417:16), <anonymous>:6140:25)
    at World.step (eval at worldInit (/home/ubuntu/me-when/server/index.js:417:16), <anonymous>:8692:31)
    at World.step (eval at worldInit (/home/ubuntu/me-when/server/index.js:418:16), <anonymous>:6285:10)
    at draw (eval at worldInit (/home/ubuntu/me-when/server/index.js:429:16), <anonymous>:382:19)
    at e.default.redraw (eval at worldInit (/home/ubuntu/me-when/server/index.js:416:16), <anonymous>:2:545491)
    at _draw (eval at worldInit (/home/ubuntu/me-when/server/index.js:416:16), <anonymous>:2:463338)
    at Timeout.task [as _onTimeout] (/home/ubuntu/me-when/server/node_modules/jsdom/lib/jsdom/browser/Window.js:552:19)

If I edit planck's code to try/catch that one function, another one appears. There's no way to tell what sprite or circumstances causes it, and thus no easy way to replicate it. It's such a frustrating issue that makes me want to just quit.

Please, any help here?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions