Skip to content

Commit 0a7d337

Browse files
authored
Log warnings when a static platform is taking to long to load (homebridge#2682)
1 parent e31f752 commit 0a7d337

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/server.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,15 @@ export class Server {
410410
private async loadPlatformAccessories(plugin: Plugin, platformInstance: StaticPlatformPlugin, platformType: PlatformName | PlatformIdentifier, logger: Logging): Promise<void> {
411411
// Plugin 1.0, load accessories
412412
return new Promise(resolve => {
413+
// warn the user if the static platform is blocking the startup of Homebridge for to long
414+
const loadDelayWarningInterval = setInterval(() => {
415+
logger.warn("%s is taking a long time to load and preventing Homebridge from starting.", plugin.getPluginIdentifier());
416+
}, 20000);
417+
413418
platformInstance.accessories(once((accessories: AccessoryPlugin[]) => {
419+
// clear the load delay warning interval
420+
clearInterval(loadDelayWarningInterval);
421+
414422
// loop through accessories adding them to the list and registering them
415423
accessories.forEach((accessoryInstance, index) => {
416424
// eslint-disable-next-line @typescript-eslint/ban-ts-comment

0 commit comments

Comments
 (0)