-
Notifications
You must be signed in to change notification settings - Fork 3.3k
v0.3.47: race condition fixes, store rehydration consolidation, other bugs #1252
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
Conversation
…riables in the code subblock (#1240) * fix(code-subblock): added validation to not parse non-variables as variables in the code subblock * fix wand prompt bar styling * fix error message for available connected blocks to only show connected available blocks, not block ID's * ui
…dlware (runtime) (#1236)
improvement(copilot): billing multiplier adjustments
…on (#1246) * fix(hydration): duplicate overlay after idle + subblocks race condition * remove random timeout * re-use correct helper * remove redundant check * add check * remove third init func
…n registry and workflow stores (#1247) * fix(race-condition-workflow-switching): another race condition between regitry and workflow stores" * fix initial load race cond + cleanup * fix initial load issue + simplify
…n users (#1250) * feat(enterprise-plan-webhooks): skip webhook queue for enterprise plan users * reuse subscription record instead of making extra db call
* fix(rehydration): consolidate store rehydration code * fix stale closure
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Greptile Summary
This PR addresses multiple critical race conditions and consolidates store rehydration logic across the workflow management system. The changes fix workflow switching race conditions by making the workflow registry the single source of truth for active workflow state, preventing inconsistent UI states that occurred when multiple stores competed to manage workflow transitions.
Key architectural improvements include:
Store Rehydration Consolidation: The Socket.IO context now uses a shared rehydrateWorkflowStores function that replaces complex merge-based state updates with complete state replacement using authoritative server data. This eliminates duplicate overlays and stale state issues during workflow switching.
Race Condition Fixes: The workflow switching logic has been simplified by removing hacky timeout-based solutions and consolidating initialization into focused useEffect hooks. The registry store now atomically updates multiple stores together, preventing the flickering and empty canvas issues that occurred during rapid workspace transitions.
Billing System Enhancements: The cost calculation system now supports separate input and output token multipliers instead of a single multiplier. This enables more granular billing control, with Copilot implementing 1.0x for input tokens (at-cost) and 1.5x for output tokens.
Enterprise Webhook Optimization: Enterprise users can now bypass the webhook queue system for immediate execution, providing better performance and reliability for high-volume webhook traffic.
UI/UX Improvements: Multiple styling fixes address dark mode visibility issues with wand prompt bars, improved error messaging for code validation, and stable workflow ordering by creation date instead of modification date.
Code Quality: The resolver now properly validates variable references to prevent parsing comparison operators or HTML tags as variables, and test coverage has been updated to match the new error message formatting.
Confidence score: 4/5
- This PR addresses complex race conditions and store synchronization issues with well-structured solutions that consolidate logic and improve reliability
- Score reflects the comprehensive nature of changes affecting multiple critical systems, requiring careful review of the state management flow and Socket.IO integration
- Pay close attention to the socket context rehydration logic and workflow switching sequences to ensure the new atomic updates work correctly across all scenarios
26 files reviewed, 5 comments
| <AlertTriangle className='h-4 w-4 cursor-pointer text-destructive' /> | ||
| </TooltipTrigger> | ||
| <TooltipContent side='top'> | ||
| <p>Invalid JSON</p> |
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.
style: The tooltip shows generic 'Invalid JSON' message but the actual schemaError state contains more specific validation messages. Consider showing the specific error in the tooltip for better user experience.
| <p>Invalid JSON</p> | |
| <p>{schemaError}</p> |
| inputMultiplier?: number, | ||
| outputMultiplier?: number |
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.
style: The optional parameters inputMultiplier and outputMultiplier should be grouped into an options object for better maintainability when dealing with multiple optional parameters.
Context Used: Context - Group optional parameters into an options object for better maintainability when defining functions or methods. (link)
| const termsUrl = process.env.NEXT_PUBLIC_TERMS_URL | ||
| if (termsUrl?.startsWith('http')) { | ||
| return NextResponse.redirect(termsUrl) | ||
| } |
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.
style: The URL validation only checks if the URL starts with 'http' but doesn't validate if it's a properly formed URL. Consider using URL constructor with try-catch for more robust validation.
| const privacyUrl = process.env.NEXT_PUBLIC_PRIVACY_URL | ||
| if (privacyUrl?.startsWith('http')) { | ||
| return NextResponse.redirect(privacyUrl) | ||
| } |
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.
style: Duplicate validation logic - consider extracting into a helper function to avoid code duplication.
| setActiveWorkflow(firstWorkflowId).then(() => { | ||
| router.replace(`/workspace/${workspaceId}/w/${firstWorkflowId}`) | ||
| }) |
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.
style: Consider adding error handling for the setActiveWorkflow promise to prevent silent failures that could leave users stuck on the loading screen
| setActiveWorkflow(firstWorkflowId).then(() => { | |
| router.replace(`/workspace/${workspaceId}/w/${firstWorkflowId}`) | |
| }) | |
| setActiveWorkflow(firstWorkflowId).then(() => { | |
| router.replace(`/workspace/${workspaceId}/w/${firstWorkflowId}`) | |
| }).catch((error) => { | |
| console.error('Failed to set active workflow:', error) | |
| // Still redirect even if setting active workflow fails | |
| router.replace(`/workspace/${workspaceId}/w/${firstWorkflowId}`) | |
| }) |
cc1f32f to
0e8e8c7
Compare
* feat(duplicate): duplicate variables when duplicating a workflow * better typing
…1255) * fix(ratelimits): enterprise and team checks should be pooled limit" * fix * fix dynamic imports * fix tests" ;
…ixed UI in dark mode issues (#1256)
Summary
Code-subblock fix: validation to not parse non-variables as variables; wand prompt bar styling; improved error messaging for connected blocks (#1240)
Whitelabel fix: move redirects (build-time) for whitelabeling to middleware
Add input/output multipliers
Improvement (Copilot): billing multiplier adjustments (#1245)
Hydration fix: prevent duplicate overlay after idle + subblocks race condition; cleanup redundant logic (#1246)
Workflow switching fix: race condition between registry and workflow stores; cleanup + simplify (#1247)
Enterprise plan webhooks feature: skip webhook queue for enterprise plan users; reuse subscription record (#1250)
Rehydration fix: consolidate store rehydration code; fix stale closure (#1249)
Sidebar fix: order by created at (#1251)