Skip to content

Conversation

@Bitshifter-9
Copy link

Implements Web IDL spec change (whatwg/webidl#1465) to upgrade QuotaExceededError from a DOMException name to a proper subclass.

Changes

  • Remove QuotaExceededError from DOMException names table in ext/web/01_dom_exception.js
  • Create QuotaExceededError class extending DOMException with quota and requested properties (default to null)
  • Update error registration in runtime/js/99_main.js to use new QuotaExceededError class
  • Add comprehensive tests for QuotaExceededError subclass in tests/unit/dom_exception_test.ts

Breaking Change

⚠️ new DOMException("message", "QuotaExceededError").code now returns 0 instead of 22 to align with the Web IDL spec.

Fixes #30028

cc @domenicImplements Web IDL spec change (whatwg/webidl#1465) to upgrade QuotaExceededError from a DOMException name to a proper subclass.

Changes:

  • Remove QuotaExceededError from DOMException names table
  • Create QuotaExceededError class extending DOMException
  • Add quota and requested properties (default to null)
  • Update error registration to use new QuotaExceededError class
  • Add comprehensive tests for QuotaExceededError subclass

Fixes #30028

@CLAassistant
Copy link

CLAassistant commented Nov 28, 2025

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link

coderabbitai bot commented Nov 28, 2025

Walkthrough

Removes the QuotaExceededError name-to-code mapping and adds a new public QuotaExceededError class extending DOMException with private fields #quota and #requested, a constructor (message = "", options = { __proto__: null }), and getters quota and requested. webidl.configureInterface(QuotaExceededError) is called and the export list now includes QuotaExceededError. Runtime code now constructs new QuotaExceededError(msg) where applicable, and unit tests validating class hierarchy, defaults, and option handling were added.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly describes the main change: upgrading QuotaExceededError to a DOMException subclass, which matches the core objective of the PR.
Description check ✅ Passed Description is directly related to the changeset, detailing the Web IDL spec implementation with specific files modified and the breaking change.
Linked Issues check ✅ Passed The PR implements both the minimal change (removing QuotaExceededError from the DOMException names table) and the extended option (implementing a proper QuotaExceededError subclass with quota and requested properties) from issue #30028.
Out of Scope Changes check ✅ Passed All changes in the PR are scoped to implementing the Web IDL spec change for QuotaExceededError. The minor formatting changes to test/bench in 99_main.js appear incidental but don't represent out-of-scope functionality.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
runtime/js/99_main.js (1)

305-315: formatException now appends an extra } to string error messages

The updated template literal for string errors:

return `Uncaught ${inspectArgs([quoteString(error, getDefaultInspectOptions())], {
  colors: !getStderrNoColor(),
})
  }`;

adds a literal } (and whitespace/newline) after the inspected string. That changes user-visible output from e.g.:

Uncaught "boom"

to something like:

Uncaught "boom"\n }

This behavior change isn’t related to the QuotaExceededError work and will confuse users and tests that rely on the formatting.

You can restore the original intent with:

-    return `Uncaught ${inspectArgs([quoteString(error, getDefaultInspectOptions())], {
-      colors: !getStderrNoColor(),
-    })
-      }`;
+    return `Uncaught ${inspectArgs(
+      [quoteString(error, getDefaultInspectOptions())],
+      { colors: !getStderrNoColor() },
+    )}`;
🧹 Nitpick comments (1)
ext/web/01_dom_exception.js (1)

196-234: QuotaExceededError subclass wiring and semantics look correct

The subclass correctly:

  • Converts message via WebIDL, fixes name to "QuotaExceededError", and defaults quota/requested to null.
  • Preserves legacy numeric constant QUOTA_EXCEEDED_ERR via the existing constants table while removing the name from nameToCodeMapping, so new DOMException("x", "QuotaExceededError").code === 0 as desired.
  • Uses webidl.configureInterface(QuotaExceededError) and assertBranded consistently with DOMException.

If you want slightly better debuggability, consider extending the Deno.privateCustomInspect handler to include quota and requested for this subclass, but that’s optional and not required to meet the spec change.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ef3192d and 71b92f2.

📒 Files selected for processing (3)
  • ext/web/01_dom_exception.js (1 hunks)
  • runtime/js/99_main.js (4 hunks)
  • tests/unit/dom_exception_test.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js}: For JavaScript runtime debugging, enable V8 inspector with --inspect-brk flag and connect Chrome DevTools to chrome://inspect
Use console.log() for debug prints in JavaScript runtime code

Files:

  • tests/unit/dom_exception_test.ts
  • ext/web/01_dom_exception.js
  • runtime/js/99_main.js
🧠 Learnings (1)
📚 Learning: 2025-11-24T16:19:37.808Z
Learnt from: CR
Repo: denoland/deno PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:19:37.808Z
Learning: Lint code using `./tools/lint.js`

Applied to files:

  • runtime/js/99_main.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: test release linux-x86_64
  • GitHub Check: test debug linux-x86_64
  • GitHub Check: test debug linux-aarch64
  • GitHub Check: test debug macos-x86_64
  • GitHub Check: test debug macos-aarch64
  • GitHub Check: test debug windows-x86_64
  • GitHub Check: build libs
🔇 Additional comments (4)
tests/unit/dom_exception_test.ts (1)

34-68: Test coverage for QuotaExceededError behavior is solid

These tests accurately exercise the new behavior:

  • Subclass chain (QuotaExceededErrorDOMExceptionError),
  • DOMException("...", "QuotaExceededError").code === 0,
  • Default quota/requested null values, and
  • Options-based initialization.

No additional scenarios are strictly necessary for this change set.

runtime/js/99_main.js (3)

79-79: Importing QuotaExceededError here is appropriate

Bringing QuotaExceededError in alongside DOMException keeps all DOM-related error builders sourced from the same module and enables the new subclass for quota errors without changing other call sites.


350-353: Using QuotaExceededError in the registered error builder is correct

Switching DOMExceptionQuotaExceededError to construct new QuotaExceededError(msg) cleanly aligns the runtime error path with the new subclass while preserving instanceof DOMException behavior for consumers.


568-569: No-op Deno.test/bench placeholders remain behaviorally unchanged

Reformatting these no-op callbacks to () => { } is purely stylistic and doesn’t affect their role as compatibility placeholders outside deno test / deno bench.

Implements Web IDL spec change (whatwg/webidl#1465) to upgrade
QuotaExceededError from a DOMException name to a proper subclass.

Changes:
- Remove QuotaExceededError from DOMException names table
- Create QuotaExceededError class extending DOMException
- Add quota and requested properties (default to null)
- Update error registration to use new QuotaExceededError class
- Add comprehensive tests for QuotaExceededError subclass

Fixes denoland#30028
@Bitshifter-9 Bitshifter-9 force-pushed the fix-quota-exceeded-error branch from 71b92f2 to 307c5ac Compare November 28, 2025 00:21
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
tests/unit/dom_exception_test.ts (1)

34-68: Tests look good, consider adding a test for QuotaExceededError.code.

The tests cover the key behaviors. However, since the PR mentions a breaking change for code, you might want to add a test verifying what new QuotaExceededError("msg").code returns (should be 22 to match QUOTA_EXCEEDED_ERR, or 0 per the new spec behavior). This would document the expected behavior explicitly.

Deno.test(function quotaExceededErrorCodeValue() {
  const error = new QuotaExceededError("test message");
  // Document expected code value for QuotaExceededError instances
  assertEquals(error.code, 0); // or 22, depending on intended behavior
});
ext/web/01_dom_exception.js (1)

196-229: Good implementation of the QuotaExceededError subclass.

The class correctly extends DOMException, uses private fields, and follows the established patterns with webidl.assertBranded.

One consideration: per the WebIDL spec, quota and requested are typed as unsigned long long?. The current implementation assigns raw values without WebIDL type conversion. If strict spec compliance is desired:

      if (ObjectHasOwn(options, "quota")) {
-       this.#quota = options.quota ?? null;
+       this.#quota = options.quota === undefined || options.quota === null
+         ? null
+         : webidl.converters["unsigned long long"](options.quota, "Failed to construct 'QuotaExceededError'", "quota");
      }
      if (ObjectHasOwn(options, "requested")) {
-       this.#requested = options.requested ?? null;
+       this.#requested = options.requested === undefined || options.requested === null
+         ? null
+         : webidl.converters["unsigned long long"](options.requested, "Failed to construct 'QuotaExceededError'", "requested");
      }

This is optional since the primary use case (internal error construction) will pass valid numbers.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 71b92f2 and 307c5ac.

📒 Files selected for processing (3)
  • ext/web/01_dom_exception.js (1 hunks)
  • runtime/js/99_main.js (4 hunks)
  • tests/unit/dom_exception_test.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js}: For JavaScript runtime debugging, enable V8 inspector with --inspect-brk flag and connect Chrome DevTools to chrome://inspect
Use console.log() for debug prints in JavaScript runtime code

Files:

  • tests/unit/dom_exception_test.ts
  • ext/web/01_dom_exception.js
  • runtime/js/99_main.js
🧠 Learnings (1)
📚 Learning: 2025-11-24T16:19:37.808Z
Learnt from: CR
Repo: denoland/deno PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:19:37.808Z
Learning: Lint code using `./tools/lint.js`

Applied to files:

  • runtime/js/99_main.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: test debug linux-aarch64
  • GitHub Check: test debug linux-x86_64
  • GitHub Check: test debug windows-x86_64
  • GitHub Check: test debug macos-aarch64
  • GitHub Check: test release linux-x86_64
  • GitHub Check: test release macos-aarch64
  • GitHub Check: test debug macos-x86_64
  • GitHub Check: build libs
🔇 Additional comments (4)
runtime/js/99_main.js (3)

79-79: LGTM!

Import correctly adds QuotaExceededError alongside DOMException.


349-354: LGTM!

The error builder now correctly returns a QuotaExceededError instance instead of constructing a DOMException with the name "QuotaExceededError". This aligns with the spec upgrade.


312-315: Whitespace-only formatting changes.

These are cosmetic changes with no functional impact.

Also applies to: 568-569

ext/web/01_dom_exception.js (1)

231-234: LGTM!

WebIDL interface configuration and exports are properly set up.

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.

Update QuotaExceededError handling

2 participants