Giter Site home page Giter Site logo

Comments (8)

bwp91 avatar bwp91 commented on September 23, 2024 1

Thanks for the changes! Have verified the plugin now, please in the future adhere to:

A GitHub release - with patch notes - should be created for every new version of your plugin.

So that each version you release has some changes from the previous version listed!

from verified.

github-actions avatar github-actions commented on September 23, 2024

✅ Pre-checks completed successfully.

from verified.

bwp91 avatar bwp91 commented on September 23, 2024

Hi @josephsamela

Couple of things:

The plugin must run on all supported LTS versions of Node.js, at the time of writing this is Node.js v16 and v18.

Please update your package version node engine to show support for node 16 (and ensure the plugin works with node 16, at least the latest version), something like this:

   "node": "^16.20.1 || ^18.17.0"

The plugin must not throw unhandled exceptions, the plugin must catch and log its own errors.

Looks like you aren't catching any errors that node-fetch might throw when requesting an invalid URL (for example the default config URL). I saved the default config, and it is repeatedly crashing my homebridge instance:

[29/07/2023, 15:19:20] [Leak Sensor] Child bridge process ended
[29/07/2023, 15:19:20] [Leak Sensor] Process Ended. Code: 1, Signal: null
[29/07/2023, 15:19:27] [Leak Sensor] Restarting Process...
[29/07/2023, 15:19:28] [Leak Sensor] Launched child bridge with PID 4636
[29/07/2023, 15:19:28] The plugin "homebridge-http-leak-sensor" requires a Homebridge version of ^1.6.0 which does not satisfy the current Homebridge version of 2.0.0-beta.1. You may need to update this plugin (or Homebridge) to a newer version. You may face unexpected issues or stability problems running this plugin.
[29/07/2023, 15:19:28] The plugin "homebridge-http-leak-sensor" requires Node.js version of ^18.17.0 which does not satisfy the current Node.js version of v20.5.0. You may need to upgrade your installation of Node.js - see https://homebridge.io/w/JTKEF
[29/07/2023, 15:19:28] Registering accessory 'homebridge-http-leak-sensor.HomebridgeHTTPLeakSensor'
[29/07/2023, 15:19:28] [Leak Sensor] Loaded homebridge-http-leak-sensor v1.0.1 child bridge successfully
[29/07/2023, 15:19:28] Loaded 0 cached accessories from cachedAccessories.0E5760A93851.
[29/07/2023, 15:19:28] Homebridge v2.0.0-beta.1 (HAP v1.0.0-beta.8) (Leak Sensor) is running on port 57457.
FetchError: invalid json response body at http://localhost/status reason: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
    at /usr/local/lib/node_modules/homebridge-http-leak-sensor/node_modules/node-fetch/lib/index.js:273:32
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at LeakSensorAccessory.handleLeakSensorSetState (/usr/local/lib/node_modules/homebridge-http-leak-sensor/src/index.ts:59:18)
[29/07/2023, 15:20:28] [Leak Sensor] Child bridge process ended
[29/07/2023, 15:20:28] [Leak Sensor] Process Ended. Code: 1, Signal: null
[29/07/2023, 15:20:35] [Leak Sensor] Restarting Process...
[29/07/2023, 15:20:36] [Leak Sensor] Launched child bridge with PID 4652

Maybe putting all of this in a try/catch

https://github.com/josephsamela/homebridge-http-leak-sensor/blob/eada06cbfb7c416b79d033b8f258da148a20b62a/src/index.ts#L58-L72

and then in the catch use this.log.warn to output the error to the homebridge log.

This would be sufficient for verification, as the plugin would no longer be crashing homebridge.

What you could do (appreciate this is a bit more involved) is try to detect whether the http response is due to:

  • a misconfigured url, or one that does not exist - and in this case cancel the interval to avoid repeated useless http calls every 60 seconds
  • a working device which is (e.g.) temporarily offline and in this case continue the interval.

Just some ideas!

from verified.

josephsamela avatar josephsamela commented on September 23, 2024

I appreciate the feedback! I'll work on incorporating the changes you suggested. Thanks!

from verified.

josephsamela avatar josephsamela commented on September 23, 2024

Hi @bwp91

I'm ready for your review. I published a new version v1.0.2 implementing the changes you suggested. Here are links to the published releases. git npm

Changes

  1. Fixed package version node engine. 1933efb
  2. Added try/catch + error logging. 1cf5c25

I also addressed your more involved suggestion:

I created a user-configurable property called failedRequestsLimit. The plugin will continue sending requests to the configured url until it hits this limit then it stop making requests. A value of 0 allows unlimited failed requests. I think this is a good middle-ground because it prevents the plugin from continuously making bad requests forever but also allows a grace period for interrupted devices to get back online.

If you have any other suggestions please let me know!

from verified.

bwp91 avatar bwp91 commented on September 23, 2024

/check

from verified.

github-actions avatar github-actions commented on September 23, 2024

✅ Pre-checks completed successfully.

from verified.

github-actions avatar github-actions commented on September 23, 2024

Congratulations! Your plugin has been verified.

You can now add the Verified by Homebridge badge to your plugin's README:

verified-by-homebridge

[![verified-by-homebridge](https://badgen.net/badge/homebridge/verified/purple)](https://github.com/homebridge/homebridge/wiki/Verified-Plugins)

Your plugin is now also eligible to display a ❤️ Donate button on its tile in the Homebridge UI. See https://github.com/oznu/homebridge-config-ui-x/wiki/Developers:-Donation-Links for instructions.

If for any reason in the future you can no longer maintain your plugin, please consider transferring it to our unmaintained plugins repo. We can take ownership until another willing developer comes along.

Thank you for your contribution to the Homebridge Community.
https://homebridge.io

from verified.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.