Skip to content

Commit 7ab3147

Browse files
committed
fix: use original block values upon retry
1 parent 9922b1b commit 7ab3147

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/pull.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ export async function executeWithRateLimitAndRetries<T>(
292292
warning(
293293
`While doing "${label}", got error "${
294294
e.message as string
295-
}". Will retry after ${secondsToWait}s...`
295+
}". Will retry after ${secondsToWait}s...`
296296
);
297297
await new Promise(resolve => setTimeout(resolve, 1000 * secondsToWait));
298298
} else {

src/transform.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,13 @@ async function doNotionToMarkdown(
163163
"notionToMarkdown.blocksToMarkdown",
164164
async () => {
165165
mdBlocks = await docunotionContext.notionToMarkdown.blocksToMarkdown(
166-
blocks
166+
// We need to provide a copy of blocks.
167+
// Calling blocksToMarkdown can modify the values in the blocks. If it does, and then
168+
// we have to retry, we end up retrying with the modified values, which
169+
// causes various issues (like using the transformed image url instead of the original one).
170+
// Note, currently, we don't do anything else with blocks after this.
171+
// If that changes, we'll need to figure out a more sophisticated approach.
172+
JSON.parse(JSON.stringify(blocks))
167173
);
168174
}
169175
);

0 commit comments

Comments
 (0)