-
Notifications
You must be signed in to change notification settings - Fork 5
Remove Promise.withResolvers usage from package detail page #1519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Promise.withResolvers usage from package detail page #1519
Conversation
It somehow caused runaway dom node creation and 100% cpu usage
WalkthroughThe package listing page removes all wiki-related data fetching, error handling, and dynamic UI logic. Loader and clientLoader no longer return wiki data. The component no longer awaits wiki content or permissions and renders a static Wiki tab. Related imports and types are removed accordingly. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor U as User
participant R as Remix loader (Before)
participant API as getPackageWiki
participant C as Component (Before)
U->>R: Request package listing
R->>API: Fetch wiki (may 404)
API-->>R: Wiki data or error
R-->>C: loader data { community, listing, team, permissions, wiki }
note over C: Suspense/Await on wiki / permission checks
C->>C: Decide if Wiki tab enabled
C-->>U: Render tabs (Wiki dynamic)
sequenceDiagram
autonumber
actor U as User
participant R as Remix loader (After)
participant C as Component (After)
U->>R: Request package listing
R-->>C: loader data { community, listing, team, permissions }
note over C: No wiki fetching or awaiting
C-->>U: Render tabs (Wiki static link)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Ah I'm dumdum. Of course it's going to cause infinite re-rendering, as the promise gets created on each re-render again. Cause I didn't put in an useEffect 🥇 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/cyberstorm-remix/app/p/packageListing.tsx (1)
168-196
: Remove Promise.withResolvers here and eliminate remaining usages across the repoThe PR’s goal is to fully remove
Promise.withResolvers
. Apply this refactor inapps/cyberstorm-remix/app/p/packageListing.tsx
, and also remove or replace the two remaining occurrences in:
packages/graph-system/src/executor.ts
packages/ts-uploader/src/uploaders/MultipartUpload.ts
Apply to
packageListing.tsx
:- // We do some trickery right here to prevent unnecessary request when the user is not logged in - let permissionsPromise = undefined; - const cu = await tools.getSessionCurrentUser(); - if (cu.username) { - const wrapperPromise = - Promise.withResolvers< - Awaited<ReturnType<typeof getPackagePermissions>> - >(); - dapper - .getPackagePermissions( - params.communityId, - params.namespaceId, - params.packageId - ) - .then(wrapperPromise.resolve, wrapperPromise.reject); - permissionsPromise = wrapperPromise.promise; - } + // Prevent unnecessary request when the user is not logged in + const cu = await tools.getSessionCurrentUser(); + const permissions = + cu?.username + ? dapper.getPackagePermissions( + params.communityId, + params.namespaceId, + params.packageId + ) + : undefined; @@ - permissions: permissionsPromise, + permissions,
🧹 Nitpick comments (2)
apps/cyberstorm-remix/app/p/packageListing.tsx (2)
77-77
: Avoid importing implementation just for typesThis import is only used to express a type in the (now removable) withResolvers block. Keeping it pulls runtime code from an internal module path and risks bundling it. After removing withResolvers, drop this import. If you still need a type, use import type.
-import { getPackagePermissions } from "@thunderstore/dapper-ts/src/methods/package"; +// (removed) type-only import no longer needed after refactor
707-721
: Consider disabling Wiki tab when no wiki existsStatic Wiki tab is fine, but if some packages don’t have a wiki, the link could route to an empty/404 state. You can mirror the Changelog pattern to disable the tab when absent.
<NewLink key="wiki" primitiveType="cyberstormLink" linkId="PackageWiki" community={listing.community_identifier} namespace={listing.namespace} package={listing.name} aria-current={currentTab === "wiki"} rootClasses={`tabs-item${ currentTab === "wiki" ? " tabs-item--current" : "" }`} + disabled={!listing.has_wiki} > Wiki </NewLink>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
apps/cyberstorm-remix/app/p/packageListing.tsx
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Generate visual diffs
- GitHub Check: ESLint
- GitHub Check: Test
- GitHub Check: CodeQL
🔇 Additional comments (1)
apps/cyberstorm-remix/app/p/packageListing.tsx (1)
203-205
: LGTM: loader data shapeuseLoaderData no longer includes wiki and carries permissions (promise | undefined). Matches the simplified UI flow.
It somehow caused runaway dom node creation and 100% cpu usage
Summary by CodeRabbit