Skip to content

Upgrade QuotaExceededError to a DOMException derived interface #1465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

domenic
Copy link
Member

@domenic domenic commented Jan 27, 2025

The proposal

The web platform benefits from having a type of exception that tells you about when you exceed quotas. In some cases, it can be helpful to tell you what the quota was, and by how much you exceeded it. webmachinelearning/writing-assistance-apis#5 gives one specific use case.

The web platform already has an exception type for telling you when you exceed quotas: it is DOMException, with the specific name property set to "QuotaExceededError". However, this does not allow carrying additional information.

This PR proposes removing "QuotaExceededError" from the list of built-in DOMException names, and instead creates a class named QuotaExceededError that derives from DOMException and has the additional optional properties quota and requested. We propose that all instances of specs that throw "QuotaExceededError" DOMExceptions get upgraded to instead throw QuotaExceededErrors. For now, such specs would leave the quota and requested properties at their default value of null, but they could eventually upgrade to include that data, if it's useful for their use case (and isn't, e.g., a privacy leak).

Alternative considered

The most promising alternative considered was to add a new class that sits alongside "QuotaExceededError" DOMException. Maybe it would be called QuotaExceededErrorWithDetails, or maybe we could even call it QuotaExceededError despite the confusion this might cause. But it would be undesirable for the web platform to have two types of quota-exceeded errors, with different APIs giving different ones. So, because we believe the compat implications are not too bad, we're interested in trying this upgrade route instead.

There are other possibilities, such as using custom bindings to sometimes add properties to base "QuotaExceededError" DOMException instances, or trying to add some generic additional information capability to the base DOMException class. However, these don't fit well with how classes work on the web platform, with getters providing predefined data on a per-class basis. They would be hacky to maintain both in specs and implementations, and a bit surprising for web developers as well due to the mismatch with other web platform classes.

Compat considerations

The following coding patterns will work unchanged if we upgrade all "QuotaExceededError" DOMExceptions to QuotaExceedErrors:

  • ex instanceof DOMException
  • ex.name === "QuotaExceededError"
  • DOMException.QUOTA_EXCEEDED_ERR === 22
  • (new DOMException("message", "QuotaExceededError")).name === "QuotaExceededError"

The following coding patterns will start giving different answers:

  • ex.constructor === DOMException
  • ex.constructor.name === "DOMException"
  • (new DOMException("message", "QuotaExceededError")).code === DOMException.QUOTA_EXCEEDED_ERR (now it will be 0)

We believe that these coding patterns are quite rare. See, for example, these GitHub search results, which show only a couple instances of .constructor testing (repeated in a few forks).

The tests like ex instanceof DOMException and ex.name === "QuotaExceededError" are much more common, and commonly seen in documentation. (See, e.g., these GitHub search results.)

Furthermore, since quotas being exceeded is a relatively rare thing to happen on the web, we suspect that the combination of these rare coding patterns with this rare type of DOMException means the impacted number of page views will be extremely small.

We could add some use counters for these coding patterns, but they would be sloppy. In particular, we could count cases where .constructor is accessed, but not cases where it is compared to DOMException, so any count would be inflated by generic constructor-accessing code, and not really tell us much about the problematic coding pattern.

Nevertheless, there's definitely some compat risk. So the best rollout plan here would probably be for Chromium to cautiously take the lead and report back if it sticks, before necessarily merging changes to all the relevant specs.


Proposed commit message:

Upgrade QuotaExceededError to a DOMException derived interface

Closes #1463.


Labeling "do not merge yet" as we should also create PRs for these specs, and we probably don't want to merge until we see if this sticks in Chromium:


  • At least two implementers are interested (and none opposed):
  • Tests are written and can be reviewed and commented upon at:
  • Implementation bugs are filed:
    • Chromium: …
    • Gecko: …
    • WebKit: …
    • Deno: …
    • Node.js: …
    • webidl2.js: …
    • widlparser: …
  • MDN issue is filed: …
  • The top of this comment includes a clear commit message to use.

(See WHATWG Working Mode: Changes for more details.)


Preview | Diff

domenic added a commit to webmachinelearning/writing-assistance-apis that referenced this pull request Mar 4, 2025
domenic added a commit to webmachinelearning/writing-assistance-apis that referenced this pull request Mar 5, 2025
domenic added a commit to webmachinelearning/writing-assistance-apis that referenced this pull request Mar 7, 2025
aarongable pushed a commit to chromium/chromium that referenced this pull request May 14, 2025
This change introduces a new QuotaExceededError class to
update the existing QuotaExceededError so services can return
`quota` and `requested` properties as needed. Implemented behind
RuntimeEnabledFlag `QuotaExceededErrorUpdate`. Changes to
update services throwing QuotaExceededError to use the new class
will be made in following changes (except for IDB which triggered
failures with this change).

Proposal: whatwg/webidl#1465
Chromestatus: https://chromestatus.com/feature/6194847180128256
Bug: 406162261
Change-Id: I68e91e15724e64c0995365ee63d4abe627fe06d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6516473
Reviewed-by: Domenic Denicola <[email protected]>
Commit-Queue: Ayu Ishii <[email protected]>
Reviewed-by: Joey Arhar <[email protected]>
Reviewed-by: Joe Mason <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1460403}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request May 14, 2025
This change introduces a new QuotaExceededError class to
update the existing QuotaExceededError so services can return
`quota` and `requested` properties as needed. Implemented behind
RuntimeEnabledFlag `QuotaExceededErrorUpdate`. Changes to
update services throwing QuotaExceededError to use the new class
will be made in following changes (except for IDB which triggered
failures with this change).

Proposal: whatwg/webidl#1465
Chromestatus: https://chromestatus.com/feature/6194847180128256
Bug: 406162261
Change-Id: I68e91e15724e64c0995365ee63d4abe627fe06d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6516473
Reviewed-by: Domenic Denicola <[email protected]>
Commit-Queue: Ayu Ishii <[email protected]>
Reviewed-by: Joey Arhar <[email protected]>
Reviewed-by: Joe Mason <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1460403}
DanielRyanSmith pushed a commit to web-platform-tests/wpt that referenced this pull request May 15, 2025
This change introduces a new QuotaExceededError class to
update the existing QuotaExceededError so services can return
`quota` and `requested` properties as needed. Implemented behind
RuntimeEnabledFlag `QuotaExceededErrorUpdate`. Changes to
update services throwing QuotaExceededError to use the new class
will be made in following changes (except for IDB which triggered
failures with this change).

Proposal: whatwg/webidl#1465
Chromestatus: https://chromestatus.com/feature/6194847180128256
Bug: 406162261
Change-Id: I68e91e15724e64c0995365ee63d4abe627fe06d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6516473
Reviewed-by: Domenic Denicola <[email protected]>
Commit-Queue: Ayu Ishii <[email protected]>
Reviewed-by: Joey Arhar <[email protected]>
Reviewed-by: Joe Mason <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1460403}

Co-authored-by: Ayu Ishii <[email protected]>
aarongable pushed a commit to chromium/chromium that referenced this pull request May 21, 2025
This change updates services that use QuotaExceededError
to use the new DOMException derived QuotaExceededError class
when the flag is enabled.

I've not been allowed to update external wpts until the webidl
spec has been updated[0][1], so this change only updates tests for
Chrome only wpts, and otherwise updates expectations for
the external ones. External wpts will be updated when the
webidl spec is merged and I am allowed to update the external
wpts (as seen in chained CL).

[0] Spec PR: whatwg/webidl#1465
[1] Discussion: web-platform-tests/wpt#52571 (comment)

Bug: 406162261
Change-Id: Ie45d6095a3e4c21e21a35d2519d268580b8bc36b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6538066
Commit-Queue: Ayu Ishii <[email protected]>
Reviewed-by: Daseul Lee <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1463139}
lando-prod-mozilla bot pushed a commit to mozilla-firefox/firefox that referenced this pull request May 22, 2025
…tion derived interface,

Automatic update from web-platform-tests
QuotaExceededError: Update to a DOMException derived interface (#52556)

This change introduces a new QuotaExceededError class to
update the existing QuotaExceededError so services can return
`quota` and `requested` properties as needed. Implemented behind
RuntimeEnabledFlag `QuotaExceededErrorUpdate`. Changes to
update services throwing QuotaExceededError to use the new class
will be made in following changes (except for IDB which triggered
failures with this change).

Proposal: whatwg/webidl#1465
Chromestatus: https://chromestatus.com/feature/6194847180128256
Bug: 406162261
Change-Id: I68e91e15724e64c0995365ee63d4abe627fe06d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6516473
Reviewed-by: Domenic Denicola <[email protected]>
Commit-Queue: Ayu Ishii <[email protected]>
Reviewed-by: Joey Arhar <[email protected]>
Reviewed-by: Joe Mason <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1460403}

Co-authored-by: Ayu Ishii <[email protected]>
--

wpt-commits: 16a71c4282b0379f639051c0a3f98f3fcdaa2149
wpt-pr: 52556

Differential Revision: https://phabricator.services.mozilla.com/D250632
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request May 22, 2025
…tion derived interface,

Automatic update from web-platform-tests
QuotaExceededError: Update to a DOMException derived interface (#52556)

This change introduces a new QuotaExceededError class to
update the existing QuotaExceededError so services can return
`quota` and `requested` properties as needed. Implemented behind
RuntimeEnabledFlag `QuotaExceededErrorUpdate`. Changes to
update services throwing QuotaExceededError to use the new class
will be made in following changes (except for IDB which triggered
failures with this change).

Proposal: whatwg/webidl#1465
Chromestatus: https://chromestatus.com/feature/6194847180128256
Bug: 406162261
Change-Id: I68e91e15724e64c0995365ee63d4abe627fe06d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6516473
Reviewed-by: Domenic Denicola <[email protected]>
Commit-Queue: Ayu Ishii <[email protected]>
Reviewed-by: Joey Arhar <[email protected]>
Reviewed-by: Joe Mason <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1460403}

Co-authored-by: Ayu Ishii <[email protected]>
--

wpt-commits: 16a71c4282b0379f639051c0a3f98f3fcdaa2149
wpt-pr: 52556

Differential Revision: https://phabricator.services.mozilla.com/D250632
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this pull request May 24, 2025
…tion derived interface,

Automatic update from web-platform-tests
QuotaExceededError: Update to a DOMException derived interface (#52556)

This change introduces a new QuotaExceededError class to
update the existing QuotaExceededError so services can return
`quota` and `requested` properties as needed. Implemented behind
RuntimeEnabledFlag `QuotaExceededErrorUpdate`. Changes to
update services throwing QuotaExceededError to use the new class
will be made in following changes (except for IDB which triggered
failures with this change).

Proposal: whatwg/webidl#1465
Chromestatus: https://chromestatus.com/feature/6194847180128256
Bug: 406162261
Change-Id: I68e91e15724e64c0995365ee63d4abe627fe06d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6516473
Reviewed-by: Domenic Denicola <[email protected]>
Commit-Queue: Ayu Ishii <[email protected]>
Reviewed-by: Joey Arhar <[email protected]>
Reviewed-by: Joe Mason <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1460403}

Co-authored-by: Ayu Ishii <[email protected]>
--

wpt-commits: 16a71c4282b0379f639051c0a3f98f3fcdaa2149
wpt-pr: 52556

Differential Revision: https://phabricator.services.mozilla.com/D250632
aarongable pushed a commit to chromium/chromium that referenced this pull request May 27, 2025
This info will be used for QuotaExceededError.requested and
QuotaExceededError.quota in a follow-up CL.

Spec: whatwg/webidl#1465

Bug: 416303646, 406162261
Change-Id: Id1d414722d2f53de0a566e8b453acdd97f501714
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6568411
Reviewed-by: Mike Wasserman <[email protected]>
Commit-Queue: Daseul Lee <[email protected]>
Reviewed-by: Emily Stark <[email protected]>
Reviewed-by: Ayu Ishii <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1466096}
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request May 28, 2025
…tion derived interface,

Automatic update from web-platform-tests
QuotaExceededError: Update to a DOMException derived interface (#52556)

This change introduces a new QuotaExceededError class to
update the existing QuotaExceededError so services can return
`quota` and `requested` properties as needed. Implemented behind
RuntimeEnabledFlag `QuotaExceededErrorUpdate`. Changes to
update services throwing QuotaExceededError to use the new class
will be made in following changes (except for IDB which triggered
failures with this change).

Proposal: whatwg/webidl#1465
Chromestatus: https://chromestatus.com/feature/6194847180128256
Bug: 406162261
Change-Id: I68e91e15724e64c0995365ee63d4abe627fe06d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6516473
Reviewed-by: Domenic Denicola <domenicchromium.org>
Commit-Queue: Ayu Ishii <ayuichromium.org>
Reviewed-by: Joey Arhar <jarharchromium.org>
Reviewed-by: Joe Mason <joenotcharlesgoogle.com>
Cr-Commit-Position: refs/heads/main{#1460403}

Co-authored-by: Ayu Ishii <ayuichromium.org>
--

wpt-commits: 16a71c4282b0379f639051c0a3f98f3fcdaa2149
wpt-pr: 52556

Differential Revision: https://phabricator.services.mozilla.com/D250632

UltraBlame original commit: 869cbd71034aec8dfdce6d5342adbfc5d8dbf8e6
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request May 28, 2025
…tion derived interface,

Automatic update from web-platform-tests
QuotaExceededError: Update to a DOMException derived interface (#52556)

This change introduces a new QuotaExceededError class to
update the existing QuotaExceededError so services can return
`quota` and `requested` properties as needed. Implemented behind
RuntimeEnabledFlag `QuotaExceededErrorUpdate`. Changes to
update services throwing QuotaExceededError to use the new class
will be made in following changes (except for IDB which triggered
failures with this change).

Proposal: whatwg/webidl#1465
Chromestatus: https://chromestatus.com/feature/6194847180128256
Bug: 406162261
Change-Id: I68e91e15724e64c0995365ee63d4abe627fe06d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6516473
Reviewed-by: Domenic Denicola <domenicchromium.org>
Commit-Queue: Ayu Ishii <ayuichromium.org>
Reviewed-by: Joey Arhar <jarharchromium.org>
Reviewed-by: Joe Mason <joenotcharlesgoogle.com>
Cr-Commit-Position: refs/heads/main{#1460403}

Co-authored-by: Ayu Ishii <ayuichromium.org>
--

wpt-commits: 16a71c4282b0379f639051c0a3f98f3fcdaa2149
wpt-pr: 52556

Differential Revision: https://phabricator.services.mozilla.com/D250632

UltraBlame original commit: 869cbd71034aec8dfdce6d5342adbfc5d8dbf8e6
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request May 28, 2025
…tion derived interface,

Automatic update from web-platform-tests
QuotaExceededError: Update to a DOMException derived interface (#52556)

This change introduces a new QuotaExceededError class to
update the existing QuotaExceededError so services can return
`quota` and `requested` properties as needed. Implemented behind
RuntimeEnabledFlag `QuotaExceededErrorUpdate`. Changes to
update services throwing QuotaExceededError to use the new class
will be made in following changes (except for IDB which triggered
failures with this change).

Proposal: whatwg/webidl#1465
Chromestatus: https://chromestatus.com/feature/6194847180128256
Bug: 406162261
Change-Id: I68e91e15724e64c0995365ee63d4abe627fe06d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6516473
Reviewed-by: Domenic Denicola <domenicchromium.org>
Commit-Queue: Ayu Ishii <ayuichromium.org>
Reviewed-by: Joey Arhar <jarharchromium.org>
Reviewed-by: Joe Mason <joenotcharlesgoogle.com>
Cr-Commit-Position: refs/heads/main{#1460403}

Co-authored-by: Ayu Ishii <ayuichromium.org>
--

wpt-commits: 16a71c4282b0379f639051c0a3f98f3fcdaa2149
wpt-pr: 52556

Differential Revision: https://phabricator.services.mozilla.com/D250632

UltraBlame original commit: 869cbd71034aec8dfdce6d5342adbfc5d8dbf8e6
aarongable pushed a commit to chromium/chromium that referenced this pull request Jun 3, 2025
This info will be used for QuotaExceededError.requested and
QuotaExceededError.quota in a follow-up CL.

Spec: whatwg/webidl#1465

(cherry picked from commit 644db35)

Bug: 416303646, 406162261
Fixed: 420952090
Change-Id: Id1d414722d2f53de0a566e8b453acdd97f501714
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6568411
Reviewed-by: Mike Wasserman <[email protected]>
Commit-Queue: Daseul Lee <[email protected]>
Reviewed-by: Emily Stark <[email protected]>
Reviewed-by: Ayu Ishii <[email protected]>
Cr-Original-Commit-Position: refs/heads/main@{#1466096}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6597962
Reviewed-by: Joe Mason <[email protected]>
Auto-Submit: Daseul Lee <[email protected]>
Commit-Queue: Rubber Stamper <[email protected]>
Bot-Commit: Rubber Stamper <[email protected]>
Cr-Commit-Position: refs/branch-heads/7204@{#416}
Cr-Branched-From: d5de512-refs/heads/main@{#1465706}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge yet Pull request must not be merged per rationale in comment
Development

Successfully merging this pull request may close these issues.

Bikeshedding help needed for generic over-limit error
2 participants