Skip to content

Conversation

@mpatfield
Copy link

Description of changes:

Since Node.js v24, fs.existsSync() will log the following deprecation warning if passed undefined.

(node:4199) [DEP0187] DeprecationWarning: Passing invalid argument types to fs.existsSync is deprecated

Here is an example full stack trace I've seen using --trace-deprecation

(node:4199) [DEP0187] DeprecationWarning: Passing invalid argument types to fs.existsSync is deprecated
    at Object.existsSync (node:fs:282:15)
    at module.exports (/var/lib/homebridge/node_modules/@homebridge-plugins/homebridge-govee/node_modules/aws-iot-device-sdk/common/lib/tls-reader.js:89:16)
    at new DeviceClient (/var/lib/homebridge/node_modules/@homebridge-plugins/homebridge-govee/node_modules/aws-iot-device-sdk/device/index.js:461:7)
    at DeviceClient (/var/lib/homebridge/node_modules/@homebridge-plugins/homebridge-govee/node_modules/aws-iot-device-sdk/device/index.js:217:14)
    at new default (file:///var/lib/homebridge/node_modules/@homebridge-plugins/homebridge-govee/lib/connection/aws.js:16:19)
    at default.pluginSetup (file:///var/lib/homebridge/node_modules/@homebridge-plugins/homebridge-govee/lib/platform.js:487:28)

The root cause is that we need to check the existence of options.keyPath before calling filesys.existsSync()

While I haven't seen it in the real world, the same is probably true of options.certPath and options.caPath

This PR checks the existence of those params first before calling existsSync() to avoid the deprecation warning.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant