-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Task bridge #6456
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
Task bridge #6456
Conversation
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.
Thank you for your contribution! I've reviewed the TaskBridge implementation and found several issues that need attention. The core functionality looks solid, but there are some critical error handling and concurrency issues that should be addressed.
|
|
||
| this.reconnectTimeout = setTimeout(() => { | ||
| this.reconnectTimeout = null | ||
| this.initialize() |
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.
Missing error handling here could lead to unhandled promise rejections. Consider wrapping this call in a try-catch block and implementing proper error recovery or logging.
| }, this.config.reconnectDelay) | ||
| } | ||
|
|
||
| private setupTaskEventListeners(task: Task) { |
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.
Potential memory leak: if this method fails partway through setting up event listeners, some listeners may remain attached without being tracked in taskEventHandlers. Consider implementing cleanup logic or using a transaction-like approach.
| this.config = { url, namespace, reconnectOnError, maxReconnectAttempts, reconnectDelay } | ||
| } | ||
|
|
||
| public static getInstance(config?: TaskBridgeConfig) { |
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.
Race condition: multiple concurrent calls to getInstance() could create multiple instances if called before the first instance is fully constructed. Consider using a lock or making the constructor async to prevent this.
| console.log(`Received task_event event for task: ${taskId}`, message.payload) | ||
| break | ||
| } | ||
| } catch (error) { |
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.
Is this error handling intentional? Message parsing errors are only logged to console but don't trigger any recovery mechanism. Should this be more robust for production use?
| await this.subscriber.unsubscribe(this.serverChannel(taskId)) | ||
| } | ||
|
|
||
| public async publish(taskId: string, type: TaskBridgeMessageType, payload: TaskBridgeMessagePayload) { |
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.
The connection check here only validates isConnected flag but doesn't verify if the Redis clients are actually ready to publish. Consider checking client.status === 'ready' as well.
src/services/task-bridge/index.ts
Outdated
| export { | ||
| type TaskBridgeConfig, | ||
| type TaskBridgeMessage, | ||
| type QueuedMessage, |
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.
The QueuedMessage interface is exported but doesn't seem to be used in the main service implementation. Is this intended for future use or should it be documented?
|
|
||
| // TODO: Figure out when to enable task bridge. | ||
| // eslint-disable-next-line no-constant-condition | ||
| if (true) { |
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.
TODO comment with hard-coded true condition - is there a plan for when this should be conditionally enabled? This might be worth addressing before merging.
No description provided.