Skip to content
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

Fix: Duplicate tweet scheduling loops in start method #1396

Closed

Conversation

jasonqindev
Copy link
Contributor

  • Resolved an issue where generateNewTweetLoop was called twice in the start method of /packages/client-twitter/src/post.ts.
  • The method was invoked at line 174 and line 190 without any conditional checks, leading to two independent tweet scheduling loops being created.
  • Removed one of the redundant generateNewTweetLoop calls to ensure only a single scheduling loop is initialized.

Fixes #1395

Relates to:

Issue #1395

Risks

Low: Removing the redundant call ensures only one scheduling loop, minimal impact on other functionalities.

Background

What does this PR do?

This PR fixes an issue where generateNewTweetLoop was called twice, leading multiple tweets to be posted. It ensures only a single scheduling loop is initialized by removing the redundant call.

What kind of change is this?

Bug fixes (non-breaking change which fixes an issue)

Documentation changes needed?

My changes do not require a change to the project documentation.

Testing

Where should a reviewer start?

Start by reviewing the start method in /packages/client-twitter/src/post.ts, focusing on the removal of the redundant generateNewTweetLoop call.

Detailed testing steps

  1. Configure the Twitter client and set POST_IMMEDIATELY=true to enable immediate tweet posting.
  2. Start the service and observe if two tweets are sent, and check if the log contains multiple Next tweet scheduled in xxx minutes messages.
  3. Verify that after starting the service, only one tweet is sent and the Next tweet scheduled in xxx minutes message is logged only once.
  4. Confirm that tweets are still being scheduled correctly without any issues.

jasonqindev and others added 2 commits December 23, 2024 16:26
- Resolved an issue where `generateNewTweetLoop` was called twice in the `start` method of /packages/client-twitter/src/post.ts.\n- The method was invoked at line 174 and line 190 without any conditional checks, leading to two independent tweet scheduling loops being created.\n- Removed one of the redundant `generateNewTweetLoop` calls to ensure only a single scheduling loop is initialized.\n\nFixes elizaOS#1395
@samarth30
Copy link
Collaborator

samarth30 commented Dec 23, 2024

I think generateNewTweetLoop(); this second loop is applied in case processActionsLoop in being executed.

if (enableActionProcessing) {
            processActionsLoop().catch((error) => {
                elizaLogger.error(
                    "Fatal error in process actions loop:",
                    error
                );
            });
            generateNewTweetLoop();
        } else {
            elizaLogger.log("Action processing loop disabled by configuration");
        }

If you can keep generateNewTweetLoop() function in the if condition then it will be good to merge

@jasonqindev
Copy link
Contributor Author

I think generateNewTweetLoop(); this second loop is applied in case processActionsLoop in being executed.

if (enableActionProcessing) {
            processActionsLoop().catch((error) => {
                elizaLogger.error(
                    "Fatal error in process actions loop:",
                    error
                );
            });
            generateNewTweetLoop();
        } else {
            elizaLogger.log("Action processing loop disabled by configuration");
        }

If you can keep generateNewTweetLoop() function in the if condition then it will be good to merge

I've updated the code to move generateNewTweetLoop() inside the if (enableActionProcessing) block as suggested.

@samarth30
Copy link
Collaborator

LGTM

@jasonqindev
Copy link
Contributor Author

It seems that this should be merged into the develop branch, but I merged it into main instead. I will close this PR and create a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple generateNewTweetLoop method invocations caused multiple tweets to be posted.
2 participants