Skip to content

htmx:targetError with conditional hx-trigger #3473

@sgdesmet

Description

@sgdesmet

I have the following polling mechanism:

<div id="poll-messages"
     hx-get="./receive"
     hx-trigger="every 1s [document.querySelector('#messages #typing-indicator') !== null] queue:none"
     hx-target="#messages #typing-indicator"
     hx-swap="outerHTML scroll:bottom"
     hx-disabled-elt="#chat-form button"
     class="is-hidden"
>

Which polls an endpoint when #typing-indicator is present, and replaces the typing indicator with the response.

However, when #typing-indicator is absent from the DOM, a htmx:targetError is logged to console every second:

htmx:targetError [email protected]:1:27520
    R https://unpkg.com/[email protected]:1
    ae https://unpkg.com/[email protected]:1
    fe https://unpkg.com/[email protected]:1
    he https://unpkg.com/[email protected]:1
    wt https://unpkg.com/[email protected]:1
    timeout https://unpkg.com/[email protected]:1
    (Async: setTimeout handler)
    ct https://unpkg.com/[email protected]:1
    timeout https://unpkg.com/[email protected]:1
    (Async: setTimeout handler)
    ct https://unpkg.com/[email protected]:1
    timeout https://unpkg.com/[email protected]:1
    (Async: setTimeout handler)
    ct https://unpkg.com/[email protected]:1
    timeout https://unpkg.com/[email protected]:1
    (Async: setTimeout handler)
    ct https://unpkg.com/[email protected]:1
    timeout https://unpkg.com/[email protected]:1
    (Async: setTimeout handler)
    ct https://unpkg.com/[email protected]:1
    timeout https://unpkg.com/[email protected]:1
    (Async: setTimeout handler)
    ct https://unpkg.com/[email protected]:1
    timeout https://unpkg.com/[email protected]:1
    (Async: setTimeout handler)
    ct https://unpkg.com/[email protected]:1
    timeout https://unpkg.com/[email protected]:1
    (Async: setTimeout handler)
    ct https://unpkg.com/[email protected]:1
    timeout https://unpkg.com/[email protected]:1
    (Async: setTimeout handler)
    ct https://unpkg.com/[email protected]:1
    timeout https://unpkg.com/[email protected]:1
    (Async: setTimeout handler)
    ct https://unpkg.com/[email protected]:1
    timeout https://unpkg.com/[email protected]:1
    (Async: setTimeout handler)
    ct https://unpkg.com/[email protected]:1
    timeout https://unpkg.com/[email protected]:1
    (Async: setTimeout handler)
    ct https://unpkg.com/[email protected]:1
    timeout https://unpkg.com/[email protected]:1
    (Async: setTimeout handler)
    ct https://unpkg.com/[email protected]:1
    timeout https://unpkg.com/[email protected]:1
    (Async: setTimeout handler)
    ct https://unpkg.com/[email protected]:1
    timeout https://unpkg.com/[email protected]:1
    (Async: setTimeout handler)
    ct https://unpkg.com/[email protected]:1
    timeout https://unpkg.com/[email protected]:1
    (Async: setTimeout handler)
    ct https://unpkg.com/[email protected]:1
    timeout https://unpkg.com/[email protected]:1
    (Async: setTimeout handler)
    ct https://unpkg.com/[email protected]:1
    timeout https://unpkg.com/[email protected]:1
    (Async: setTimeout handler)
    ct https://unpkg.com/[email protected]:1
    timeout https://unpkg.com/[email protected]:1

The GET request to the receive endpoint is not executed as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions