Skip to content

Conversation

@nikelborm
Copy link
Contributor

Motivation

Quoted from WebAudio/web-midi-api#278 PR description:

According to Web IDL spec on InvalidAccessError:

Deprecated. Use TypeError for invalid arguments, "NotSupportedError" DOMException for unsupported operations, and "NotAllowedError" DOMException for denied requests instead.

Previously, while trying to open MIDIPort, "InvalidAccessError" DOMException was thrown when...

the device is unavailable (e.g., is already in use by another process and cannot be opened, or is disconnected)

In this case, I believe NotAllowedError fits well, according to its Web IDL spec description:

The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.

Security and permissions reasons are only a subset of the appropriate causes, according to this definition. An attempt to open the port can fail. Somebody's exclusive lock on the port, or the port being disconnected, is the current context driving the platform's decision not to allow the operation.

And in the context of forbidden .send calls:

If data is a System Exclusive message, and the MIDIAccess did not enable System Exclusive access, throw an InvalidAccessError exception.

NotAllowedError fits even better, because it fits an explicitly defined subset of permission errors.

Related issues and pull requests

The change in spec: WebAudio/web-midi-api@3795f22

This PR should not be confused with #41956, which talks about SecurityErrors instead

@nikelborm nikelborm requested a review from a team as a code owner December 9, 2025 23:10
@nikelborm nikelborm requested review from wbamberg and removed request for a team December 9, 2025 23:10
@github-actions github-actions bot added Content:WebAPI Web API docs size/xs [PR only] 0-5 LoC changed labels Dec 9, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2025

Preview URLs

Flaws (2)

URL: /en-US/docs/Web/API/MIDIOutput/send
Title: MIDIOutput: send() method
Flaw count: 1

  • broken_links:
    • /en-US/docs/Web/Security/Secure_Contexts is a redirect

URL: /en-US/docs/Web/API/MIDIPort/open
Title: MIDIPort: open() method
Flaw count: 1

  • broken_links:
    • /en-US/docs/Web/Security/Secure_Contexts is a redirect

@nikelborm nikelborm changed the title MIDI APIs now use NotAllowedError instead of InvalidAccessError MIDI APIs now use NotAllowedError instead of InvalidAccessError Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:WebAPI Web API docs size/xs [PR only] 0-5 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant