Skip to content

fix: handle NotAllowedError from audio.play()#22

Merged
Just-Insane merged 1 commit into
devfrom
seer/fix/handle-audio-play-notallowederror
Jun 3, 2026
Merged

fix: handle NotAllowedError from audio.play()#22
Just-Insane merged 1 commit into
devfrom
seer/fix/handle-audio-play-notallowederror

Conversation

@sentry

@sentry sentry Bot commented Jun 3, 2026

Copy link
Copy Markdown

Description

This PR addresses issue SABLE-3B, where NotAllowedError was being thrown by audioElement?.play() calls in src/app/pages/client/ClientNonUIFeatures.tsx (lines 200 and 274) and resulting in unhandled promise rejections.

The root cause was that these specific play() calls lacked a .catch() handler. Browsers like Safari reject the promise returned by play() with a NotAllowedError when autoplay is blocked due to the absence of a recent user gesture. This unhandled rejection was being reported as an error.

The fix involves adding .catch(() => {}) to both instances of audioElement?.play() in ClientNonUIFeatures.tsx. This aligns the behavior with other play() calls in the codebase (e.g., in useVoiceRecorder.ts, useCallSignaling.ts) that already gracefully handle this scenario by silently swallowing the rejection. The intended behavior remains unchanged: if autoplay is blocked, the sound simply won't play, but no unhandled error will occur.

Fixes SABLE-3B

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

AI disclosure:

  • Partially AI assisted (clarify which code was AI assisted and briefly explain what it does).
  • Fully AI generated (explain what all the generated code does in moderate detail).

Fixes SABLE-3B

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

⚠️ Missing changeset

This pull request does not include a changeset. Please add one before requesting review so the change is properly documented and included in the release notes.

How to add a changeset:

  1. Run pnpm run document-change (interactive) and commit the generated file, or
  2. Manually create .changeset/<descriptive-name>.md:
---
default: patch
---

Short user-facing summary of the change.

Replace patch with major, minor, patch, docs, or note as appropriate.

📖 Read more in CONTRIBUTING.md.

If this PR is internal/maintenance with no user-facing impact, a maintainer can add the internal label to skip this check.

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

Status Preview URL Commit Alias Updated (UTC)
✅ Deployment successful! https://pr-22-sable.justin-tech.workers.dev c382a3f pr-22 Wed, 03 Jun 2026 11:06:45 GMT

@Just-Insane Just-Insane marked this pull request as ready for review June 3, 2026 13:09
Copilot AI review requested due to automatic review settings June 3, 2026 13:09
@Just-Insane Just-Insane merged commit ca7ca13 into dev Jun 3, 2026
11 of 12 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to prevent unhandled promise rejections caused by HTMLMediaElement.play() failing with NotAllowedError (e.g., autoplay restrictions) in ClientNonUIFeatures.tsx, aligning notification-sound playback behavior with other parts of the codebase.

Changes:

  • Added promise rejection handling to two notification-sound audioElement.play() calls.
  • Ensured invite and message notification sound playback no longer produces unhandled rejections when playback is blocked.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 199 to 201
const audioElement = audioRef.current;
audioElement?.play();
audioElement?.play().catch(() => {});
clearMediaSessionQuickly();
Comment on lines 273 to 275
const audioElement = audioRef.current;
audioElement?.play();
audioElement?.play().catch(() => {});
clearMediaSessionQuickly();
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.

2 participants