-
Notifications
You must be signed in to change notification settings - Fork 111
docs: update entry.ts example in API Pipelining section #623
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
Conversation
|
📝 WalkthroughSummary by CodeRabbit
WalkthroughDocumentation updates to API pipelining examples: route handling now accepts string or object, uses a nullable template with guards, defers parsing until template exists, requires loader presence, passes config with params to loader, and breaks after the first successful loader invocation. Changes
Sequence Diagram(s)sequenceDiagram
participant Pipeline as Pipeline Runner
participant Activity as Activity
participant Template as Route Template
participant Matcher as Matcher
participant Loader as Loader
Pipeline->>Activity: Iterate activities
alt route is string
Pipeline->>Template: makeTemplate({ path })
else route is object
Pipeline->>Template: makeTemplate(route)
end
Pipeline-->>Pipeline: if no template -> continue
Pipeline->>Matcher: parse(location), compute match
Pipeline-->>Pipeline: if !match or !loader -> continue
Pipeline->>Loader: loader({ params, config })
Pipeline-->>Pipeline: break after first successful call
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ 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
Status, Documentation and Community
|
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: 2
🔭 Outside diff range comments (1)
docs/pages/api-references/future-api/api-pipelining.ko.mdx (1)
58-58: JSX에 불필요한 콤마가 있어 화면에 ','가 렌더링될 수 있습니다내부의 <Stack ... />, 뒤 콤마는 JSX 자식으로 문자열 ','을 추가합니다. 제거하세요.
- <Stack initialLoaderData={initialLoaderData} />, + <Stack initialLoaderData={initialLoaderData} />
🧹 Nitpick comments (2)
docs/pages/api-references/future-api/api-pipelining.en.mdx (1)
35-35: Clarify that initialLoaderData is a Promise when not awaitedGiven the “do not await” guidance, initialLoaderData will hold a Promise. Consider reflecting this in the sample for clarity (helps readers understand why Suspense works).
Outside this range, you can adjust the declaration to make the intent explicit:
- let initialLoaderData: unknown | null = null; + // Holds a Promise when a loader is matched (intentionally not awaited) + let initialLoaderData: Promise<unknown> | null = null;docs/pages/api-references/future-api/api-pipelining.ko.mdx (1)
35-35: await하지 않으므로 Promise 타입임을 명확히 해주세요주석대로 await하지 않으면 initialLoaderData에는 Promise가 들어갑니다. 독자의 이해를 돕기 위해 타입을 명시적으로 표현하는 것이 좋아요.
이 범위 밖 선언부를 다음과 같이 조정할 수 있어요:
- let initialLoaderData: unknown | null = null; + // 매칭 시 loader의 Promise를 담습니다 (await하지 않음) + let initialLoaderData: Promise<unknown> | null = null;
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
docs/pages/api-references/future-api/api-pipelining.en.mdx(1 hunks)docs/pages/api-references/future-api/api-pipelining.ko.mdx(1 hunks)
🔇 Additional comments (2)
docs/pages/api-references/future-api/api-pipelining.en.mdx (1)
25-27: Nice defensive gating and control-flowThe explicit t guard and deferring parse until after template creation look good. Gating on both match existence and loader presence keeps the loop tight and avoids unnecessary work.
Also applies to: 29-31
docs/pages/api-references/future-api/api-pipelining.ko.mdx (1)
25-27: 수비적인 가드와 제어 흐름 좋습니다t 존재 여부를 먼저 확인하고, 템플릿 생성 이후에만 parse를 수행하는 점이 안전합니다. match와 loader 모두를 게이트하는 것도 불필요한 작업을 줄여줍니다.
Also applies to: 29-31
| if (typeof activity.route === "string") { | ||
| t = makeTemplate({ path: activity.route }); | ||
| } else if (typeof activity.route === "object") { | ||
| t = makeTemplate(activity.route); | ||
| } |
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.
Guard against null when treating route as an object
typeof null === "object". If activity.route can ever be nullish, makeTemplate(activity.route) would throw. Add a null check before the object branch.
- } else if (typeof activity.route === "object") {
- t = makeTemplate(activity.route);
+ } else if (activity.route && typeof activity.route === "object") {
+ t = makeTemplate(activity.route);
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (typeof activity.route === "string") { | |
| t = makeTemplate({ path: activity.route }); | |
| } else if (typeof activity.route === "object") { | |
| t = makeTemplate(activity.route); | |
| } | |
| if (typeof activity.route === "string") { | |
| t = makeTemplate({ path: activity.route }); | |
| } else if (activity.route && typeof activity.route === "object") { | |
| t = makeTemplate(activity.route); | |
| } |
🤖 Prompt for AI Agents
In docs/pages/api-references/future-api/api-pipelining.en.mdx around lines 19 to
23, the branch treats activity.route as an object but does not guard against
null (since typeof null === "object"), so calling makeTemplate(activity.route)
can throw; update the conditional to ensure activity.route is not nullish before
calling makeTemplate (e.g., check activity.route != null && typeof
activity.route === "object" or equivalent) so only actual objects are passed to
makeTemplate, and handle the null/undefined case as appropriate.
| if (typeof activity.route === "string") { | ||
| t = makeTemplate({ path: activity.route }); | ||
| } else if (typeof activity.route === "object") { | ||
| t = makeTemplate(activity.route); | ||
| } |
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.
null을 객체로 취급하는 것을 방지하세요
typeof null === "object" 이므로, activity.route가 nullish일 경우 makeTemplate(activity.route)가 예외를 던질 수 있어요. 객체 분기에서 null 체크를 추가해 주세요.
- } else if (typeof activity.route === "object") {
- t = makeTemplate(activity.route);
+ } else if (activity.route && typeof activity.route === "object") {
+ t = makeTemplate(activity.route);
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (typeof activity.route === "string") { | |
| t = makeTemplate({ path: activity.route }); | |
| } else if (typeof activity.route === "object") { | |
| t = makeTemplate(activity.route); | |
| } | |
| if (typeof activity.route === "string") { | |
| t = makeTemplate({ path: activity.route }); | |
| } else if (activity.route && typeof activity.route === "object") { | |
| t = makeTemplate(activity.route); | |
| } |
🤖 Prompt for AI Agents
docs/pages/api-references/future-api/api-pipelining.ko.mdx lines 19-23: 현재 분기에서
typeof null === "object"여서 activity.route가 null일 때 makeTemplate(activity.route)를
호출하면 예외가 발생할 수 있습니다; 객체 분기 앞에서 activity.route가 null 또는 undefined가 아닌지 확인하거나
typeof activity.route === "object" && activity.route !== null로 조건을 변경해 null을 걸러낸
뒤 makeTemplate을 호출하도록 수정하세요.
| if (typeof activity.route === "string") { | ||
| t = makeTemplate({ path: activity.route }); | ||
| } else if (typeof activity.route === "object") { | ||
| t = makeTemplate(activity.route); | ||
| } |
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.
In the previous documentation, only a single case was provided as an example.
Since there was only one example, copying and pasting the example code from the document would result in an error.
However, in actual use cases, activity.route can be either an object or a string, so we need to handle both cases.
Therefore, we have updated the example code to accommodate the above scenarios.
|
|
||
| // 1. Request API data (do not await) | ||
| initialLoaderData = activity.loader({ params: match as any }); | ||
| initialLoaderData = activity.loader({ params: match as any, config }); |
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.

No description provided.