-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Implement per-page workflow system for sync-threads to overcome API limits #1941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement per-page workflow system for sync-threads to overcome API limits #1941
Conversation
- Create SyncThreadsCoordinatorWorkflow to spawn separate workflows per page - Modify SyncThreadsWorkflow to support single-page mode - Update ZeroDriver.triggerSyncWorkflow to use coordinator workflow - Add fallback to original workflow if coordinator fails - Update isSyncing method to check both coordinator and original workflows - Configure new coordinator workflow in wrangler.jsonc for all environments - Export new coordinator workflow from main.ts and add to env types This solves the API request limit issue by distributing requests across multiple workflow instances instead of processing all pages sequentially in a single workflow instance. Co-Authored-By: Adam <github@ajxb.net>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Bug Report
Comments? Email us. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Join our Discord community for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Bug Report
Comments? Email us. |
Bug Report
Comments? Email us. |
Bug Report
Comments? Email us. |
Bug Report
Comments? Email us. |
|
An error occured. This error may be due to rate limits. If this error persists, please email us. |
fda0c3b to
66c6ee0
Compare
Bug Report
Comments? Email us. |
… clarity and consistency
Bug Report
Comments? Email us. |
Implement per-page workflow system for sync-threads to overcome API limits
Summary
This PR implements a new coordinator-based workflow system to solve Cloudflare Workflow API request limitations when syncing user email threads. Instead of processing all pages sequentially in a single workflow instance (which hits API limits), the system now creates separate workflow instances for each page of threads.
Key Changes:
SyncThreadsCoordinatorWorkflow- orchestrates page-by-page processingSyncThreadsWorkflow- now supports both single-page and multi-page modesThe coordinator processes pages sequentially as requested: lists first page → creates page workflow → waits for completion → moves to next page until
nextPageTokenis null.Review & Testing Checklist for Human
SYNC_THREADS_COORDINATOR_WORKFLOWbindings are correctly deployed in all environments (dev/staging/prod)Recommended Test Plan:
Diagram
%%{ init : { "theme" : "default" }}%% graph TD Agent["apps/server/src/routes/agent/index.ts<br/>ZeroDriver.triggerSyncWorkflow()"]:::major-edit Coordinator["apps/server/src/workflows/<br/>sync-threads-coordinator-workflow.ts<br/>(NEW FILE)"]:::major-edit SyncWorkflow["apps/server/src/workflows/<br/>sync-threads-workflow.ts<br/>SyncThreadsWorkflow"]:::major-edit EnvTypes["apps/server/src/env.ts<br/>ZeroEnv interface"]:::minor-edit MainExports["apps/server/src/main.ts<br/>exports"]:::minor-edit WranglerConfig["apps/server/wrangler.jsonc<br/>workflow bindings"]:::minor-edit Agent -->|"triggers coordinator<br/>instead of direct sync"| Coordinator Coordinator -->|"creates page workflow<br/>for each page"| SyncWorkflow Coordinator -->|"waits for completion<br/>via polling"| SyncWorkflow EnvTypes -.->|"defines workflow types"| Agent MainExports -.->|"exports new coordinator"| Coordinator WranglerConfig -.->|"configures bindings"| Coordinator subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
SyncThreadsWorkflowmaintains multi-page mode for existing workflows