Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions docs/pages/api-references/future-api/api-pipelining.en.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,25 @@ async function main() {
let initialLoaderData: unknown | null = null;

for (const activity of config.activities) {
const t = makeTemplate({ path: activity.route });
const match = t.parse(location.pathname + location.search);
let t: ReturnType<typeof makeTemplate> | null = null;

if (typeof activity.route === "string") {
t = makeTemplate({ path: activity.route });
} else if (typeof activity.route === "object") {
t = makeTemplate(activity.route);
}
Comment on lines +19 to +23
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

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.

Suggested change
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.

Comment on lines +19 to +23
Copy link
Contributor Author

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.

image

However, in actual use cases, activity.route can be either an object or a string, so we need to handle both cases.

image

Therefore, we have updated the example code to accommodate the above scenarios.


if (!match) {
if (!t) {
continue;
}

const match = t.parse(location.pathname + location.search);
if (!match || !activity.loader) {
continue;
}

// 1. Request API data (do not await)
initialLoaderData = activity.loader({ params: match as any });
initialLoaderData = activity.loader({ params: match as any, config });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We also updated the code to inject config due to the type error shown in the image below.

image

break;
}

Expand Down
18 changes: 14 additions & 4 deletions docs/pages/api-references/future-api/api-pipelining.ko.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,25 @@ async function main() {
let initialLoaderData: unknown | null = null;

for (const activity of config.activities) {
const t = makeTemplate({ path: activity.route });
const match = t.parse(location.pathname + location.search);
let t: ReturnType<typeof makeTemplate> | null = null;

if (typeof activity.route === "string") {
t = makeTemplate({ path: activity.route });
} else if (typeof activity.route === "object") {
t = makeTemplate(activity.route);
}
Comment on lines +19 to +23
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

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.

Suggested change
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 (!match) {
if (!t) {
continue;
}

const match = t.parse(location.pathname + location.search);
if (!match || !activity.loader) {
continue;
}

// 1. API 데이터를 요청해요 (await하지 않아요)
initialLoaderData = activity.loader({ params: match as any });
initialLoaderData = activity.loader({ params: match as any, config });
break;
}

Expand Down
Loading