Skip to content

Better freeze error traceability#153

Merged
garronej merged 1 commit intomainfrom
better_freeze_error_tracability
Jan 28, 2026
Merged

Better freeze error traceability#153
garronej merged 1 commit intomainfrom
better_freeze_error_tracability

Conversation

@garronej
Copy link
Copy Markdown
Collaborator

@garronej garronej commented Jan 28, 2026

Summary by CodeRabbit

  • Refactor
    • Strengthened runtime protections to prevent unauthorized modifications to core APIs, with earlier and more consistent enforcement.
    • Broadened coverage to include additional built‑ins and symbol-based keys, ensuring attempts to modify protected properties are reliably caught.
    • Standardized error behavior for write attempts to protected APIs for clearer, uniform outcomes.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 28, 2026

📝 Walkthrough

Walkthrough

Introduces a centralized defineProperty interception mechanism that overrides Object.defineProperty and registers per-property interceptors across prototypes and global objects; centralizes error creation and expands the exported ApiName union to include "Object".

Changes

Cohort / File(s) Summary
Centralized Property Definition Interception
src/core/earlyInit_browserRuntimeFreeze.ts
Added definePropertyInterceptors and a guarded override of Object.defineProperty. Replaced dispersed throw logic with local createWriteError helpers and per-property interceptors. Registered interception hooks for numerous APIs/prototypes (window APIs, Function.prototype.call, iterator prototypes, crypto, navigator.serviceWorker, etc.), added symbol property handling, refactored to use local o/p variables, and extended ApiName union to include "Object".

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I nibble on lines where properties freeze,
I stitch interceptors through protos with ease,
When writers approach, a gentle error springs,
One guarded gate now watches many things,
Hooray for safe fields and snug little keys!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Better freeze error traceability' directly relates to the main change: centralizing error handling and interception mechanisms to improve error traceability in the runtime freeze system.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@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: 1

🤖 Fix all issues with AI agents
In `@src/core/earlyInit_browserRuntimeFreeze.ts`:
- Around line 203-224: The code is redefining navigator.serviceWorker even when
it doesn't exist, which makes feature-detection like 'serviceWorker' in
navigator return true; update the block that sets const original = navigator[p]
(where p = "serviceWorker") to first check if original is undefined/null and if
so skip the Object.defineProperty and the definePropertyInterceptors.push
call—i.e., only protect the property when navigator[p] actually exists; keep
using createWriteError_local for the thrown error and leave the getter/setter
and interceptor behavior unchanged when the API is present.

Comment thread src/core/earlyInit_browserRuntimeFreeze.ts Outdated
@garronej garronej force-pushed the better_freeze_error_tracability branch from d70e45a to ee960b3 Compare January 28, 2026 01:15
@garronej garronej merged commit dd42153 into main Jan 28, 2026
6 checks passed
@garronej garronej deleted the better_freeze_error_tracability branch January 28, 2026 01:20
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.

1 participant