Skip to content

Waves X embed fix on Decks#747

Merged
feruzm merged 4 commits into
developfrom
wave
Apr 8, 2026
Merged

Waves X embed fix on Decks#747
feruzm merged 4 commits into
developfrom
wave

Conversation

@feruzm
Copy link
Copy Markdown
Member

@feruzm feruzm commented Apr 7, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Improved abort/cancellation handling so operations stop cleanly; aborted requests now return a clear client-disconnected response and cleanup failures emit warnings instead of being swallowed.
    • Made left-channel cleanup abort-aware and log warnings on failure.
  • Performance

    • Propagated cancellation signals across async flows, network requests, and subscription loading to reduce wasted work and improve responsiveness.
  • Style

    • Constrained embedded Twitter content to prevent overflow and layout issues.
  • Chores

    • Updated package versions and changelogs.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 7, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3744a948-6fb2-4f5d-950f-f3076c194a8a

📥 Commits

Reviewing files that changed from the base of the PR and between 180d1d3 and aa8c8da.

⛔ Files ignored due to path filters (6)
  • packages/sdk/dist/browser/index.js is excluded by !**/dist/**
  • packages/sdk/dist/browser/index.js.map is excluded by !**/dist/**, !**/*.map
  • packages/sdk/dist/node/index.cjs is excluded by !**/dist/**
  • packages/sdk/dist/node/index.cjs.map is excluded by !**/dist/**, !**/*.map
  • packages/sdk/dist/node/index.mjs is excluded by !**/dist/**
  • packages/sdk/dist/node/index.mjs.map is excluded by !**/dist/**, !**/*.map
📒 Files selected for processing (4)
  • packages/sdk/CHANGELOG.md
  • packages/sdk/package.json
  • packages/wallets/CHANGELOG.md
  • packages/wallets/package.json

📝 Walkthrough

Walkthrough

Merged abort signal (client + timeout) is introduced and threaded through the Mattermost bootstrap route and server helpers; React Query and RPC queryFns now accept/forward cancellation signals; CSS limits Twitter embed sizing; package versions and changelogs updated.

Changes

Cohort / File(s) Summary
Bootstrap route
apps/web/src/app/api/mattermost/bootstrap/route.ts
Create merged AbortSignal.any([req.signal, ac.signal]), use merged signal for all downstream operations, register an abort listener to cancel React Query, make left-channel cleanup abort-aware and log warnings on failures.
Mattermost server helpers
apps/web/src/server/mattermost.ts
Add optional signal?: AbortSignal to exported helpers and propagate signal into mmFetch requests and internal call chains (user/team/channel/token/membership functions).
Query cancellation
packages/sdk/src/modules/accounts/queries/get-account-subscriptions-query-options.ts
Update React Query queryFn to accept TanStack context and forward context.signal into callRPC to enable cancellation.
Renderer styling
apps/web/src/styles/renderer.css
Add .ecency-renderer-twitter-extension and .er-twitter-frame rules to constrain Twitter embeds (max-width: 100%, overflow: hidden).
SDK & wallets packages
packages/sdk/CHANGELOG.md, packages/sdk/package.json, packages/wallets/CHANGELOG.md, packages/wallets/package.json
Bump packages/sdk to 2.1.6 and packages/wallets to 3.0.6; add changelog entries reflecting the SDK update.

Sequence Diagram

sequenceDiagram
    participant Client as HTTP Request
    participant Route as Bootstrap Route
    participant Signal as AbortSignal.any()
    participant QueryCache as ReactQuery Cache
    participant Mattermost as Mattermost Helpers
    participant MMFetch as mmFetch

    Client->>Route: POST /mattermost/bootstrap
    Route->>Route: create timeout controller (ac)
    Route->>Signal: merge req.signal + ac.signal
    Signal-->>Route: combined signal returned

    Route->>QueryCache: prepare subscriptions query key/options
    Route->>Signal: register abort listener -> QueryCache cancelQueries(key)

    Route->>Mattermost: ensureMattermostUser(username, signal)
    Mattermost->>MMFetch: mmFetch(..., { signal })
    MMFetch-->>Mattermost: response

    Route->>Mattermost: ensureUserInTeam(userId, signal)
    Mattermost->>MMFetch: mmFetch(..., { signal })
    MMFetch-->>Mattermost: response

    Route->>Mattermost: ensurePersonalToken(userId, signal)
    Mattermost->>MMFetch: mmFetch(..., { signal })
    MMFetch-->>Mattermost: response

    alt Abort triggered (client cancel or timeout)
        Signal->>QueryCache: cancelQueries(key)
        Signal->>Mattermost: propagate AbortError to mmFetch
        Route-->>Client: 499 if req.signal aborted, else timeout handling
    end

    Route->>Signal: remove abort listener (finally)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🐰 I stitched the signals with a twitch and a hop,
Queries bow out quick when the timeout goes pop,
Fetches mind the leash, cleanup warns if it fails,
Channels keep tidy trails and no panic prevails. 🥕✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title "Waves X embed fix on Decks" is misleading; the changes primarily focus on abort signal handling for Mattermost operations and abort-aware subscriptions loading, not on Twitter/X embed fixes. Update the title to reflect the actual primary changes, such as "Add abort signal support to Mattermost bootstrap operations" or "Implement abort signal handling for server operations and subscriptions".
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wave

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/web/src/app/api/mattermost/bootstrap/route.ts (1)

166-172: ⚠️ Potential issue | 🟡 Minor

Skip the warning on expected aborts in the left-channel lookup.

getMattermostUserWithProps() now receives signal, so normal request cancellation can land in this catch. In that case this warning is noise, and Line 172 immediately turns the flow back into the abort path anyway. Re-throw when signal.aborted and keep the warning for real fetch failures.

🔧 Suggested fix
     try {
       const userWithProps = await getMattermostUserWithProps(user.id, signal);
       leftChannels = getUserLeftChannels(userWithProps);
     } catch (e) {
+      if (signal.aborted) {
+        throw e;
+      }
       console.warn("MM bootstrap: failed to load left channels", { username, error: e });
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/src/app/api/mattermost/bootstrap/route.ts` around lines 166 - 172,
The catch around getMattermostUserWithProps / getUserLeftChannels is noisy for
expected aborts; inside the catch block check signal.aborted and re-throw the
error when aborted, otherwise keep the console.warn using the existing context
(username, error) so only real fetch failures are logged; update the catch that
currently logs "MM bootstrap: failed to load left channels" to re-throw if
signal.aborted and only call console.warn when not aborted.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/web/src/app/api/mattermost/bootstrap/route.ts`:
- Around line 25-38: The merged signal created with AbortSignal.any([req.signal,
ac.signal]) needs to distinguish timeout vs caller cancellation and handle
pre-aborted signals: before attaching the listener used in the Promise.race,
check if req.signal.aborted or ac.signal.aborted (or the merged signal.aborted)
and immediately reject with the appropriate AbortError so pre-aborted
cancellation wins; in the catch path use ac.signal.aborted (not signal.aborted)
to detect the 30s timeout so the log message accurately reports a timeout only
when ac.signal caused the abort; ensure the event listener attachment on signal
only occurs if neither req.signal nor ac.signal are already aborted.

---

Outside diff comments:
In `@apps/web/src/app/api/mattermost/bootstrap/route.ts`:
- Around line 166-172: The catch around getMattermostUserWithProps /
getUserLeftChannels is noisy for expected aborts; inside the catch block check
signal.aborted and re-throw the error when aborted, otherwise keep the
console.warn using the existing context (username, error) so only real fetch
failures are logged; update the catch that currently logs "MM bootstrap: failed
to load left channels" to re-throw if signal.aborted and only call console.warn
when not aborted.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 04e6971f-d7c1-43dd-b8b2-4c3166d8fc94

📥 Commits

Reviewing files that changed from the base of the PR and between 0267a63 and 543618e.

📒 Files selected for processing (1)
  • apps/web/src/app/api/mattermost/bootstrap/route.ts

Comment thread apps/web/src/app/api/mattermost/bootstrap/route.ts Outdated
@feruzm feruzm added the patch Bug fixes and patches (1.0.0 → 1.0.1), add this only if any packages/ have patch changes in PR label Apr 8, 2026
@feruzm feruzm merged commit 13aa6d7 into develop Apr 8, 2026
1 check was pending
@feruzm feruzm deleted the wave branch April 8, 2026 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Bug fixes and patches (1.0.0 → 1.0.1), add this only if any packages/ have patch changes in PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant