Skip to content

Commit 18294f0

Browse files
authored
fix handleDeltaChanges with correct lastBuildTime type (#290)
### Description The `lastBuildTime` variable was incorrectly typed as a `Date`, while it is actually a `string` returned by the cache system. This caused a silent runtime error: `toISOString is not a function` which resulted in the delta check always failing and all documents being re-synced. This commit corrects the type and ensures proper handling of `lastBuildTime`. ### Testing 1. Run `gatsby develop` twice. 2. On the second run, verify that only changed documents are synced with Sanity. Co-authored-by: David Saitta <>
1 parent 6e3d478 commit 18294f0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/gatsby-source-sanity/src/util/handleDeltaChanges.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default async function handleDeltaChanges({
2424
config,
2525
}: {
2626
args: SourceNodesArgs
27-
lastBuildTime: Date
27+
lastBuildTime: string
2828
client: SanityClient
2929
syncWithGatsby: SyncWithGatsby
3030
config: PluginConfig
@@ -35,7 +35,7 @@ export default async function handleDeltaChanges({
3535
const changedDocs = await client.fetch<SanityDocument[]>(
3636
'*[!(_type match "system.**") && _updatedAt > $timestamp]',
3737
{
38-
timestamp: lastBuildTime.toISOString(),
38+
timestamp: lastBuildTime,
3939
},
4040
)
4141
changedDocs.forEach((doc) => {

0 commit comments

Comments
 (0)