Why would delay cause crash?

I have a strange crash from yesterday evening: a delay in a script below causes whole script to crash and stop. In settings -->automations and scripts → if i trace script execution this error is entered:

Stopped because of unknown reason at 17. september 2025 ob 12:56:30 (runtime: 0.26 seconds)

This script worked for years, nothing has been changed long. If i delete delay script executes perfectly, while no matter where i insert delay it stops there.

Any clues? Only thing i remember doing is update browser mod…

izklop_tablice:
  alias: Izklop tablice
  mode: single
  sequence:
    - action: input_boolean.turn_on
      data:
        entity_id: input_boolean.izklop_tablice
    - action: script.turn_off
      data:
        entity_id: script.vklop_tablice
    - action: button.press
      data:
        entity_id: button.pavle_dimmer_off
    - action: browser_mod.navigate
      data:
        path: /pavle-soba/0
        browser_id:
          - pavle-tab-s5
# problematic entry here:
    - delay:
        seconds: 2
# end of problem
    - action: input_boolean.turn_off
      data:
        entity_id: input_boolean.izklop_tablice
    - if:
        - condition: state
          entity_id: sun.sun
          state: "above_horizon"
        - condition: time
          after: "08:30:00"
          before: "21:00:00"
      then:
        - action: switch.turn_off
          data:
            entity_id: switch.galaxy_tab_s5e_screen
      else:
        - action: browser_mod.navigate
          data:
            path: /pavle-soba/ura
            browser_id:
              - pavle-tab-s5
    - action: rest_command.kiosk_pavlesoba_oled_volume_80

Try keeping the delay but commenting out the preceding browser_mod action.

Your logs likely have more information related to this.

I tried that and got same result, which points out that browser mod is not the culprit.

I didn’t find any entries in my HA log, other than misterious “script already running”, which is very strange. But if it was running then it was “locked”, since it was stuck at certain point - i know that because i inserted “notify.,send_message” after each action and wrote comments into a file to see where it stops. It always stopped just before delay command. But, just to be sure now i changed script mode from single to restart.

And to be even more baffled, thing mysteriously started to work now, so i can’t explore any further until it dies again.
Before i published this post i restarted HA a few times, i even restarted HAOS and even whole proxmox server. From then to now i didn’t do anything except updated button card. There were some error entries in log about button card before recent update:

2025-09-17 13:09:06.752 ERROR (MainThread) [frontend.js.modern.202509035] Uncaught error from Edge 140.0.0.0 on Windows 10

TypeError: this._$AH.handleEvent is not a function

Q.handleEvent (/hacsfiles/button-card/button-card.js:1:14233)

but that couldn’t be related… or could be?

Not really, since you say that then things started mysteriously running.

The kind of behavior you’re describing suggests a problem–it could be with a custom integration or it could be with some other aspect of the system–that might be manifesting at different times in different ways due to race conditions (or for that same reason sometimes not manifesting at all).

One thing people sometimes suggest is to disable integrations one at a time to see if stability improves. Sometimes that’s not really an option, though, and another way to go about this is what Petro suggested, except you need to make sure you are increasing the verbosity of logging done in your integrations and by HA.

Yeah, i agree, first thing to do in such cases is to disable addons one-by-one. I’ll have to do that if i don’t find the culprit.
I found some options to enable debug logging for hacs, i’ll try that if/when thing breaks again, perhaps it will give me some more data to work with.

That means something in the automation is blocking it from finishing running.

Indeed… so, i guess only option is to increase log level and wait.
I always forget in which direction to go… currently i have logger set to “warn”. If i’m correct setting it to “debug” will give me more entries (and also increase HA’s workload, i guess), correct? Which level is recommended in normal conditions anyway?

debug will provide the most amount of logging

1 Like

To the extent you are controlling the logging level for multiple components, you probably don’t want to set everything to debug all at once–it might be a fire hose.

1 Like