Poll for Completion
User Intent
"I want to know when a feed has finished its initial sync"
Operation
SDK Method:
graphlit.isFeedDone()GraphQL:
isFeedDonequeryEntity Type: Feed
Common Use Cases: Wait for initial feed sync, verify feed completion before querying content
TypeScript (Canonical)
import { Graphlit } from 'graphlit-client';
const graphlit = new Graphlit();
// After creating a feed
const feedResponse = await graphlit.createFeed(feedInput);
const feedId = feedResponse.createFeed.id;
console.log(`Feed created: ${feedId}`);
// Poll for completion
const maxAttempts = 60; // 10 minutes max (60 * 10 seconds)
for (let attempts = 1; attempts <= maxAttempts; attempts++) {
const status = await graphlit.isFeedDone(feedId);
if (status.isFeedDone.result) {
console.log('Feed sync complete!');
const contents = await graphlit.queryContents({
feeds: [{ id: feedId }],
});
console.log(`Synced ${contents.contents.results.length} items`);
return;
}
console.log(`Still syncing... (${attempts}/${maxAttempts})`);
await new Promise((resolve) => setTimeout(resolve, 10_000));
}
console.log('Feed sync timeout - still processing');Python:
C#:
Parameters
Required
id(string): Feed ID to check
Response
Developer Hints
Only for Initial Sync
isFeedDone() indicates initial sync completion, not ongoing monitoring:
Important: Once initial sync completes, the feed continuously monitors for new content automatically.
Recommended Polling Interval
Why 10 seconds?: Balance between responsiveness and API efficiency. Initial feed syncs typically take 1-10 minutes depending on content volume.
🕐 Timeout Considerations
Helper Function Pattern
Variations
1. Basic Polling with Progress
Simple polling with progress updates:
2. Polling with Content Count Tracking
Track synced content during polling:
3. Parallel Feed Polling
Poll multiple feeds simultaneously:
4. Exponential Backoff Polling
Reduce API calls with backoff:
5. Polling with Timeout Promise
Use Promise.race for cleaner timeout:
6. Query Content After Completion
Complete workflow from feed creation to content query:
Common Issues
Issue: isFeedDone() always returns false
Solution: Feed may be stuck. Check feed state with getFeed(). Look for error state.
Issue: Polling times out but feed has content Solution: Feed may be partially synced but not "done". Increase timeout or query content anyway.
Issue: Feed not found error
Solution: Verify feed ID is correct. Check that feed wasn't deleted.
Issue: Feed completes immediately (no content synced) Solution: Check feed configuration. May have OAuth token issues or incorrect settings.
Issue: Memory leak from long polling Solution: Ensure you have proper timeout/max attempts. Don't poll indefinitely.
Production Example
Poll helper function:
Last updated
Was this helpful?