Fix crashes, modernize dependencies, improve editor reliability#25
Open
dxdc wants to merge 12 commits into
Open
Fix crashes, modernize dependencies, improve editor reliability#25dxdc wants to merge 12 commits into
dxdc wants to merge 12 commits into
Conversation
1c479ec to
cb7d5cb
Compare
…rite_attribute nodes
b5d5372 to
2cfc6fe
Compare
Author
|
heads up, massive pr here, but I think I caught all of the major bugs from the earlier version. I reorganized everything by feature/commit to make it a lot easier to review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes multiple Node-RED-crashing bugs, updates the Matter SDK from 0.11.9 to 0.16.11, overhauls the editor UI for reliable cascading dropdowns, fills missing cluster definitions, and adds device discovery methods.
Note: The
node_modules/removal is in a separate PR.Breaking Changes
fabricLabelconfig field - existing configs continue to work (defaults to the controller Name).Crash Fixes
command is not a functionfatal error - All cluster method lookups usedeval()which returnedundefinedfor nonexistent methods, then callingundefined()killed Node-RED. Replaced with bracket notation plustypeofguards across 6 files.Decommission crash during reconnect -
conn.decommission()had no.catch(). The error from attempting to decommission a reconnecting device was unhandled and crashed Node-RED.Null controller crashes -
RED.nodes.getNode()returns null if the controller is deleted or undeployed. Every node immediately dereferenced it without checking.BigInt crash on unconfigured nodes -
BigInt("")andBigInt("__SELECT__")throwSyntaxError. Event and subscribe nodes parse the device ID at creation time, so a half-configured node crashed Node-RED on deploy.command.js
Object.keys(undefined)- IfevaluateNodePropertyerrored, execution continued with_dataasundefined. Also failed on non-object types like strings.command.js missing endpoint fallback - The only node without
|| 1onsplit('-')[1]. Simple devices gotgetDeviceById(NaN)→ null → crash.Matter SDK UDP "Not running" crash - The SDK throws from inside a Promise constructor when the dgram socket closes during CASE session teardown on redeploy. Added a
process.uncaughtExceptionhandler scoped to@matter//@project-chip/stack frames that logs these as warnings instead of crashing.Matter SDK CASE Sigma2 rejection crash - Added a matching
process.unhandledRejectionhandler for promise rejections originating in the SDK's session resumption layer (e.g. CASE Sigma2 errors), which would otherwise crash Node-RED as unhandled rejections.Unhandled promise rejections -
connectNode()calls across all node types and editor API endpoints lacked.catch()handlers.simpleMode dropdown crash -
setCommand()andsetAttribute()calledsimpleCommands[cluster].includes()andsimpleAttributes[cluster].includes()without null-checking the lookup first. When a cluster had no entry in the simpleCommands/simpleAttributes objects, this threwTypeError: Cannot read properties of undefined. Added guards matching the existing safe pattern ingetCommands()/getAttributes().The "Matter Test" Name Issue
Two independent bugs:
id="node-input-name"but config nodes requirenode-config-input-prefix.adminFabricLabelpassed to SDK - Added a new "Fabric Label" config field, falls back to Name.Editor UI Overhaul
Cascading dropdowns - Selecting a controller auto-populates devices, selecting a device auto-populates clusters, selecting a cluster auto-populates commands/attributes/events. Uses an initialization guard flag (
_initDoneset after 500ms) so the cascade handlers don't fire during editor open and wipe saved values from async restoration.Empty-state feedback - Clusters with no events show "No events available for this cluster" as a disabled option instead of just
--SELECT--.Node labels - Added
isRealValue()andgetSelectedText()helpers. Labels only showdeviceName | fieldwhen both are genuine values.oneditsaveusesgetSelectedText()instead of blindly readinginnerHTML, preventing--SELECT--from leaking into labels.Runtime deploy-time feedback - Rather than editor validation (which fundamentally conflicts with async-populated selects), incomplete configs are caught on deploy with status indicators: red "no controller", yellow "not configured", red "invalid event"/"invalid attribute".
Broken jQuery selectors fixed -
$('node-input-command')missing#,$('node-input-attribute')referencing wrong ID, both using nonexistent"changed"event.Other editor fixes - simpleMode checkbox not persisting on Event nodes, tautological
||/&&guard conditions (8 occurrences), toggleMethod not called on editor open, missing methodType default, device list race conditions with shared globals, 30-second timeout for unreachable devices, clearSelect vs resetSelect to avoid clobbering downstream values.New Features
listEndpointsmanager method - Returns all endpoints on a device with their device types, names, and cluster summaries (id + name). Useful for discovering what a device exposes without needing the full attribute/command detail.describemanager method - Returns the complete device structure: all endpoints, each with their clusters, and each cluster with its full list of attributes and commands. Wireinject → mattermanager (describe) → debugto discover exactly what a device supports - helpful for finding clusters like RelativeHumidityMeasurement (1029) on unexpected endpoints.Missing Cluster Definitions Filled
The
simpleCommandsandsimpleAttributesobjects were missing entries for many clusters listed insimpleClusters, causing the simpleMode filter to hide all options for those clusters. All entries verified against the Matter SDK source innode_modules/@matter/types/src/clusters/.simpleCommands added: 28 (PulseWidthModulation), 72 (OvenCavityOperationalState), 73 (OvenMode), 81 (LaundryWasherMode), 82 (RefrigeratorMode), 84 (RvcRunMode), 85 (RvcCleanMode), 89 (DishwasherMode), 157 (EnergyEvseMode), 159 (DeviceEnergyManagementMode)
simpleAttributes added: 28 (PulseWidthModulation), 31 (AccessControl), 72 (OvenCavityOperationalState), 73 (OvenMode), 87 (RefrigeratorAlarm), 93 (DishwasherAlarm), 97 (RvcOperationalState), 113 (HepaFilterMonitoring), 114 (ActivatedCarbonFilterMonitoring), 157 (EnergyEvseMode), 159 (DeviceEnergyManagementMode), 1036–1071 (all ConcentrationMeasurement clusters: CO, CO₂, NO₂, O₃, PM2.5, formaldehyde, PM1, PM10, TVOC, radon)
Dependency Updates
@matter/main:^0.11.9→^0.16.11@project-chip/matter.js:^0.11.9→^0.16.11All runtime APIs verified compatible. Removed 20+ unused imports from controller.js and manager.js (copy-pasted from the TypeScript example file, never referenced at runtime).
Housekeeping
"main": "index.js"(no such file), added"files"field for npm publishnode.on('close')handlers for clean shutdown on controller, event, subscribelet/constthroughout1expression afterbreak;in controller.jsclusertypo in editor.js global declarationsconsole.logstatements, upgraded error logs toconsole.warndone()callback in command.js for proper catch node supportgetCommandOpts()inside async callback (was firing before dropdown populated)