0x5e / homebridge-tuya-platform

Make homebridge-tuya-platform great again.
MIT License
206 stars 58 forks source link

Crashing With Syntax Error - NodeJS 18 #380

Open JackMoseley2001 opened 9 months ago

JackMoseley2001 commented 9 months ago

Prerequisite

Cache

Version

1.7.0-beta.49

Device Infomation JSON File

No response

Device Control Mode

None

Logs

Registering platform '@0x5e/homebridge-tuya-platform.TuyaPlatform'
[Tuya] Loaded @0x5e/homebridge-tuya-platform v1.7.0-beta.49 child bridge successfully
Loaded 20 cached accessories from cachedAccessories.<uid>.
[Tuya] Loading accessory from cache: Plug
[Tuya] Loading accessory from cache: Smart Plug
[Tuya] Loading accessory from cache: Smart Plug 2
[Tuya] Loading accessory from cache: Smart Plug 3
[Tuya] Loading accessory from cache: Smart Plug 4
[Tuya] Loading accessory from cache: Dimmer switch
[Tuya] Loading accessory from cache: Dimmer switch 2
[Tuya] Loading accessory from cache: Dimmer switch 3
[Tuya] Loading accessory from cache: Smart Wall Socket
[Tuya] Loading accessory from cache: Smart Wall Socket 2
[Tuya] Loading accessory from cache: Smart Wall Socket 3
[Tuya] Loading accessory from cache: Smart Bedside Lamp
[Tuya] Loading accessory from cache: Smart on-off
[Tuya] Loading accessory from cache: LED Strip Lights
[Tuya] Loading accessory from cache: LED Strip Lights 2
[Tuya] Loading accessory from cache: On-off device(WIFI+BLE)
[Tuya] Loading accessory from cache: Smart two-color light strip
[Tuya] Loading accessory from cache: On-off device(WIFI+BLE) 2
[Tuya] Loading accessory from cache: Sideboard Sockets
[Tuya] Loading accessory from cache: Lounge Sockets
[Tuya] Log in to Tuya Cloud.
[Tuya] [TuyaOpenAPI] Login to: https://openapi.tuyaeu.com
Homebridge v1.6.1 (HAP v0.11.1) (Tuya) is running on port 43860.
[Tuya] Start MQTT connection.
[Tuya] Fetching home list.
[Tuya] Got home_id=<id>, name=My Home ..
[Tuya] Fetching device list.
Fetching scene list.
Got scene_id=<id>, name=Goodnight
Got 21 device(s) and scene(s).
Device list saved at /var/lib/homebridge/persist/TuyaDeviceList.<id>.json
SyntaxError: Invalid or unexpected token
    at node:internal/fs/promises:356:38
    at TuyaPlatform.initDevices (/homebridge/node_modules/@0x5e/homebridge-tuya-platform/src/platform.ts:191:5)
    at HomebridgeAPI.<anonymous> (/homebridge/node_modules/@0x5e/homebridge-tuya-platform/src/platform.ts:128:7)
[Tuya] Child bridge process ended

Other Infomations

Hi 👋

Not sure quite sure what's causing this, just randomly started a couple days ago.

No new devices having been added / no config changes, but now the plugin is unfortunately stuck in a boot loop where it's crashing after saving the device list - just wondered if there's any suggestions or ideas? It appears to be crashing at this line, but the file is being created and not finding any syntax errors in the file, so not quite sure what's happening here.

Our instance is running NodeJS v18.13.0, not sure if this is supported - although this is one thing I think potentially could have changed?

Thank you in advance for any help 🙏

JackMoseley2001 commented 9 months ago

Just to add more findings on this:

It appears that this is an issue with the upgrade to NodeJS 18 - which is really a requirement going forward as NodeJS 16 has now been deprecated and not supported. NodeJS 18 is the latest LTS version and I'll take a look at providing a PR that provides the necessary updates.

0x5e commented 9 months ago

@JackMoseley2001 Thanks in advance, I may not experienced in node/js/ts, welcome to submit PR!