EvenAR / node-simconnect

A cross platform SimConnect client library for Node.JS
GNU Lesser General Public License v3.0
95 stars 33 forks source link

Fix: undefined property access #58

Closed knokbak closed 1 year ago

knokbak commented 1 year ago

I was running into an issue where, when the simulator was not running, I got the following error in the utils/registry.ts file at line 14:

TypeError: Cannot read properties of undefined (reading 'SimConnect_Port_IPv4')

This pull request resolves this issue by returning undefined if the key does not exist:

const values: { [key: string]: any } = result[FS_KEY]?.values;
resolve(values ? values[subKey].value : undefined);

I've also added connectionParameters.ts line 16-18 to handle cases where undefined is returned.

EvenAR commented 1 year ago

@knokbak thanks for the PR. I have included these changes in 3.2.3-beta.1 . Can you test it and confirm it's working as expected?

knokbak commented 1 year ago

@EvenAR sorry for the delay. all working as intended for me!