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 an issue with methods interacting with unblocking mechanisms #13055

Merged
merged 9 commits into from Mar 12, 2024

Conversation

nachocodoner
Copy link
Member

@nachocodoner nachocodoner commented Mar 6, 2024

OSS-352

Context: #13054 (comment)

Reproduction

Describe the next methods in the server.

let events = [];

Meteor.methods({
  async 'unblockedMethod'({ delay }) {
    events.push('unblock start');
    this.unblock();
    await Meteor._sleepForMs(delay);
    events.push('unblock end');
  },
  'blockingMethod'() {
    events.push('blockingMethod');
  },
});

Run on the client:

Meteor.callAsync("unblockedMethod", { delay: 200 }); // unblock + sleep for 20 milliseconds
Meteor.callAsync("blockingMethod"); // run straight + block

// assert 1: `events` should have `["unblock start", "blockingMethod"]` at this point as two methods are executed in parallel and the first one is unblocked. 
// assert 2: `events` should have added `["unblock end"]` at some point in the future as `unblockedMethod` finished

Check how the test is described on the PR. A failing scenario that reproduce the issue is depicted in the next picture. Warning logs Method took too long also showed up.

image

Fix

The fix relied on ensure the client queue triggers next method after the stub(simulation) finished for the previous one. This also fixed the logs.

image

@nachocodoner nachocodoner added the Meteor 3 relates to Meteor 3 label Mar 6, 2024
@nachocodoner nachocodoner mentioned this pull request Mar 7, 2024
@nachocodoner nachocodoner changed the title Fix an issue with method interacting with unblocking mechanisms Fix an issue with methods interacting with unblocking mechanisms Mar 7, 2024
@nachocodoner nachocodoner marked this pull request as ready for review March 11, 2024 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Meteor 3 relates to Meteor 3 Project:DDP
Projects
None yet
4 participants