fix(plugin-multiplayer-sync): use pluginAPI.setTimeout for minimum_wait - #63
Closed
jodeleeuw wants to merge 1 commit into
Closed
fix(plugin-multiplayer-sync): use pluginAPI.setTimeout for minimum_wait#63jodeleeuw wants to merge 1 commit into
jodeleeuw wants to merge 1 commit into
Conversation
…it so the pending timeout is cleaned up on abort Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Routes the
minimum_waitdelay inholdMinimumWait()throughthis.jsPsych.pluginAPI.setTimeout()instead of a rawsetTimeout, so the pending timeout is registered with jsPsych and cleaned up automatically if the trial or experiment is aborted mid-wait. This matches the convention used by the core plugins (e.g.plugin-html-keyboard-response).The spec's
MockApi(which stands in forpluginAPIin the direct-trial()tests) gains a matchingsetTimeouthelper that delegates to the real timer. Includes a patch changeset.This ports the same fix that briefly landed on jspsych/jsPsych#3694 before the plugin was removed from that PR in favor of this repo (commit 5512c5b5 there).
Heads-up (out of scope here)
While porting this I noticed
src/index.tsstill reads the multiplayer API offthis.jsPsych.pluginAPI("flattened onto pluginAPI by jsPsych core", src/index.ts:111–113). jsPsych#3694 has since moved the API to a top-leveljsPsych.multiplayernamespace, so this plugin will need a follow-up to read fromjsPsych.multiplayeronce that PR merges.Test plan
npx jestinpackages/plugin-multiplayer-sync— 12/12 passnpx tsc --noEmit— clean🤖 Generated with Claude Code