Skip to content

Conversation

@stephenmjerge
Copy link

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: 8a6b8fb

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

This PR includes changesets to release 1 package
Name Type
@jspsych/plugin-audio-button-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

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

1 participant