Skip to content

Commit 2660e7c

Browse files
committed
small fix
1 parent be2222d commit 2660e7c

File tree

3 files changed

+84
-46
lines changed

3 files changed

+84
-46
lines changed

www/apps/book/app/learn/best-practices/third-party-sync/page.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Before diving into best practices, it's important to understand the general appr
3131

3232
[Workflows](../../fundamentals/workflows/page.mdx) are special functions designed for long-running, asynchronous tasks. They provide features like [compensation](../../fundamentals/workflows/compensation-function/page.mdx), [retries](../../fundamentals/workflows/retry-failed-steps/page.mdx), and [async execution](../../fundamentals/workflows/long-running-workflow/page.mdx) that are essential for reliable data syncing.
3333

34-
When defining your syncing logic, such as pushing product data to a third-party API or pulling inventory data into Medusa, you should define a workflow that encapsulates this logic.
34+
When defining your syncing logic, such as pushing product data to a third-party service or pulling inventory data into Medusa, you should define a workflow that encapsulates this logic.
3535

3636
Medusa also exposes [built-in workflows](!resources!/medusa-workflows-reference) for common commerce operations, like creating or updating products, that you can leverage in your syncing logic.
3737

@@ -67,9 +67,9 @@ If you've set up [server and worker instances](../../production/worker-mode/page
6767

6868
</Note>
6969

70-
In the scheduled job or subscriber, you retrieve the data to be synced from the third-party API or from Medusa itself. Then, you execute the workflow, passing it the data to be synced.
70+
In the scheduled job or subscriber, you retrieve the data to be synced from the third-party service or from Medusa itself. Then, you execute the workflow, passing it the data to be synced.
7171

72-
For example, the following scheduled job fetches products from a third-party API and syncs them to Medusa using a workflow:
72+
For example, the following scheduled job fetches products from a third-party service and syncs them to Medusa using a workflow:
7373

7474
```ts title="src/jobs/sync-products.ts"
7575
import { MedusaContainer } from "@medusajs/framework/types"
@@ -392,7 +392,7 @@ First, install the `stream-json` library in your Medusa project:
392392
npm install stream-json @types/stream-json
393393
```
394394

395-
Then, use it in your scheduled job or subscriber to stream and parse JSON data from the third-party API:
395+
Then, use it in your scheduled job or subscriber to stream and parse JSON data from the third-party service:
396396

397397
export const streamDataHighlights = [
398398
["19", "nodeStream", "Create a Node.js Readable stream from the response body"],
@@ -510,9 +510,9 @@ In the above snippet, you catch stream errors and check for specific error codes
510510

511511
### Retrieve Only Necessary Fields
512512

513-
A common performance pitfall when syncing data is retrieving more fields than necessary from third-party APIs or Medusa's [Query](../../fundamentals/module-links/query/page.mdx). This leads to increased data size, slower performance, and higher memory usage.
513+
A common performance pitfall when syncing data is retrieving more fields than necessary from third-party services or Medusa's [Query](../../fundamentals/module-links/query/page.mdx). This leads to increased data size, slower performance, and higher memory usage.
514514

515-
When retrieving data from third-party APIs or with Medusa's Query, only request the necessary fields. Then, to efficiently group existing data for updates, use a [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) for quick lookups.
515+
When retrieving data from third-party services or with Medusa's Query, only request the necessary fields. Then, to efficiently group existing data for updates, use a [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) for quick lookups.
516516

517517
For example, don't retrieve all product fields like this:
518518

@@ -655,7 +655,7 @@ export default async function syncProductsJob(container: MedusaContainer) {
655655

656656
In the above snippet, you define two async generators:
657657

658-
1. `streamProductsFromApi`: Yields individual products from the third-party API one at a time.
658+
1. `streamProductsFromApi`: Yields individual products from the third-party service one at a time.
659659
2. `batchProducts`: Takes an async generator of products and yields them in batches of a specified size.
660660

661661
Then, in your scheduled job, you consume these generators using [for await...of](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of) loops to process product batches incrementally.
@@ -724,7 +724,7 @@ This approach keeps memory usage controlled and prevents the system from being o
724724

725725
Errors can occur during data syncing due to transient network issues, rate limiting, or temporary unavailability of third-party services. To improve reliability, implement retry logic with exponential backoff for transient errors.
726726

727-
For example, implement a custom function that fetches data with retry logic, then use it to fetch data from the third-party API:
727+
For example, implement a custom function that fetches data with retry logic, then use it to fetch data from the third-party service:
728728

729729
export const retryHighlights = [
730730
["1", "MAX_RETRIES", "Maximum number of retry attempts"],

www/apps/book/generated/edit-dates.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,5 +137,5 @@ export const generatedEditDates = {
137137
"app/learn/codemods/replace-imports/page.mdx": "2025-10-09T11:37:44.754Z",
138138
"app/learn/fundamentals/admin/translations/page.mdx": "2025-10-30T11:55:32.221Z",
139139
"app/learn/configurations/medusa-config/asymmetric-encryption/page.mdx": "2025-10-31T09:53:38.607Z",
140-
"app/learn/best-practices/third-party-sync/page.mdx": "2025-12-03T10:42:53.362Z"
140+
"app/learn/best-practices/third-party-sync/page.mdx": "2025-12-03T11:48:58.209Z"
141141
}

0 commit comments

Comments
 (0)