Skip to content

Handle in-flight request cancellation in billing hook#130

Merged
NessieCanCode merged 1 commit intomainfrom
fix-usebillingdata-hook-to-handle-cancellations
Sep 9, 2025
Merged

Handle in-flight request cancellation in billing hook#130
NessieCanCode merged 1 commit intomainfrom
fix-usebillingdata-hook-to-handle-cancellations

Conversation

@NessieCanCode
Copy link
Owner

Summary

  • add cockpit detection constant and abort support to useBillingData
  • track loading state so previous billing results remain until refresh completes
  • update App to use new loading flag

Testing

  • make check

https://chatgpt.com/codex/tasks/task_e_68bf9e186dc88324a2df8456530d7367

@NessieCanCode NessieCanCode merged commit 9ee2e68 into main Sep 9, 2025
0 of 4 checks passed
@NessieCanCode NessieCanCode deleted the fix-usebillingdata-hook-to-handle-cancellations branch September 9, 2025 03:31
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment on lines 99 to 103
} catch (e) {
console.error(e);
if (requestIdRef.current === id) {
if (e.name !== 'AbortError') {
console.error(e);
setError(e.message || String(e));
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Treat cancelled cockpit.spawn as non-errors

When aborting an in‑flight request the catch block only ignores exceptions whose name is 'AbortError'. cockpit.spawn rejects with objects whose problem is 'cancelled' rather than that name, so cancelling the previous request (e.g. when switching months quickly or unmounting) will still trigger console.error and populate error. The UI therefore flashes a load failure even though the cancellation was expected and a replacement request is underway.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant