Skip to content

Conversation

@stephenmjerge
Copy link
Contributor

Summary

Fix InvalidStateError in audio-button-response when a response ends the trial while audio is still playing and trial_ends_after_audio is true. Remove ended listeners before calling stop() so the stop()-triggered ended event doesn’t re-enter end_trial on a fresh, not-started source node.

Reproduction

  • response_ends_trial: true (default)
  • response_allowed_while_playing: true (default)
  • trial_ends_after_audio: true
  • Click a button while the audio is still playing → console shows: Failed to execute 'stop' on 'AudioScheduledSourceNode': cannot call stop without calling start first.

Testing

  • npm test (Node 18)

Fixes #3553

@changeset-bot
Copy link

changeset-bot bot commented Nov 19, 2025

🦋 Changeset detected

Latest commit: 3f92887

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@jspsych/plugin-audio-keyboard-response Patch
@jspsych/plugin-audio-button-response Patch
@jspsych/plugin-audio-slider-response Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@jadeddelta jadeddelta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appreciate the contribution @stephenmjerge! i went ahead and added the same fix to the other audio-* plugins, and we should be good to go. thanks once more!

@jadeddelta jadeddelta merged commit 7adb82b into jspsych:main Jan 22, 2026
2 checks passed
@github-actions github-actions bot mentioned this pull request Jan 22, 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.

audio-button-response: stopping audio early causes error

2 participants