Skip to content

fix(plugin-multiplayer-sync): use pluginAPI.setTimeout for minimum_wait - #63

Closed
jodeleeuw wants to merge 1 commit into
mainfrom
fix/minimum-wait-pluginapi-settimeout
Closed

fix(plugin-multiplayer-sync): use pluginAPI.setTimeout for minimum_wait#63
jodeleeuw wants to merge 1 commit into
mainfrom
fix/minimum-wait-pluginapi-settimeout

Conversation

@jodeleeuw

Copy link
Copy Markdown
Member

Summary

Routes the minimum_wait delay in holdMinimumWait() through this.jsPsych.pluginAPI.setTimeout() instead of a raw setTimeout, 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 for pluginAPI in the direct-trial() tests) gains a matching setTimeout helper 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.ts still reads the multiplayer API off this.jsPsych.pluginAPI ("flattened onto pluginAPI by jsPsych core", src/index.ts:111–113). jsPsych#3694 has since moved the API to a top-level jsPsych.multiplayer namespace, so this plugin will need a follow-up to read from jsPsych.multiplayer once that PR merges.

Test plan

  • npx jest in packages/plugin-multiplayer-sync — 12/12 pass
  • npx tsc --noEmit — clean

🤖 Generated with Claude Code

…it so the pending timeout is cleaned up on abort

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jodeleeuw

Copy link
Copy Markdown
Member Author

Closing as redundant: the identical fix landed on main via d7cccc7 (Hannah's independent port of the same jsPsych#3694 commit) and the #62 merge resolution, which also brought the correct Promise<void> typing. The changeset need is covered by #62's patch entry for plugin-multiplayer-sync.

@jodeleeuw jodeleeuw closed this Jul 24, 2026
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.

1 participant