Skip to content

useAnalyticsQuery can stay loading or later transition to error after HTTP 200 on JSON_ARRAY SSE requests #497

Description

@hjonasson

Following up from 496

I have observed cases where useAnalyticsQuery returns an HTTP 200 for a JSON_ARRAY analytics request, but the hook remains in a loading state and later transitions to an error state.

I cannot reproduce this deterministically yet, but I have seen it happen a few times in a test app created with databricks apps init and got a screenshot on one of those instances:

Image

Some investigation I have done.

On the JSON_ARRAY path, an HTTP 200 only means the SSE transport opened successfully via connect-sse.ts:71 and passed the initial response.ok check in connect-sse.ts:80. The hook sets loading to true before starting the request in use-analytics-query.ts:434, and on the JSON_ARRAY branch it opens a per-instance SSE connection in use-analytics-query.ts:487 and use-analytics-query.ts:501. The hook only clears loading once a terminal SSE payload is processed: either type === "result" in use-analytics-query.ts:179 and use-analytics-query.ts:180, or type === "error" in use-analytics-query.ts:190 and use-analytics-query.ts:195. From a consumer point of view, this can look like a successful request that never actually resolves at the hook level.

Happy to help further if you think this is worth fixing.

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