-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(hue): Address various nil field index issues
The majority of these fixes are concurrency races: Due to Hue's heavy usage of additional Cosock coroutines, it can be the case that functions that have been passed references to device records will be operating on a device record for a deleted device. This can cause unexpected nil index errors and crashes. We attempt to minimize that here with heuristics; in particular, a device that has been deleted will return `nil` for *any* of its table keys. So we check a field that we *know* a device record should have, its `.id` field. We wrap all handlers in a closure that does a sanity check on the status of the device record using this heuristic, and we wrap the handler itself in a pcall. We also address some one-off locations where nil field indexes can occur for other reasons, and introduce some additional defensiveness around other places where we've observed nil index crashes in crash metrics.
- Loading branch information
Showing
3 changed files
with
104 additions
and
57 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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