Skip to content

refactor: with WeakRef in element APIs and WASM bindings to improve m…#2439

Open
PupilTong wants to merge 3 commits intolynx-family:mainfrom
PupilTong:p/hw/use-weak-ref-dom-handle
Open

refactor: with WeakRef in element APIs and WASM bindings to improve m…#2439
PupilTong wants to merge 3 commits intolynx-family:mainfrom
PupilTong:p/hw/use-weak-ref-dom-handle

Conversation

@PupilTong
Copy link
Copy Markdown
Collaborator

@PupilTong PupilTong commented Apr 9, 2026

…emory management.

Summary by CodeRabbit

  • Refactor

    • Switched to weak references for DOM elements and added periodic GC during idle time to remove stale references.
    • Event and style flows now handle collected elements and surface runtime errors instead of throwing, improving stability.
  • New Features

    • Runtime binding now supports safe set/remove attribute operations that noop if the element was collected.
  • Tests

    • Tests updated to expect weak-reference-based element handling.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).
  • Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).

@PupilTong PupilTong self-assigned this Apr 9, 2026
@PupilTong PupilTong requested a review from Sherry-hue as a code owner April 9, 2026 06:01
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 9, 2026

🦋 Changeset detected

Latest commit: 965bd1f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@lynx-js/web-core Patch
upgrade-rspeedy Patch
@lynx-js/web-rsbuild-server-middleware Patch
@lynx-js/template-webpack-plugin Patch
@lynx-js/react-rsbuild-plugin Patch
create-rspeedy Patch
@lynx-js/web-worker-rpc Patch
@lynx-js/react-alias-rsbuild-plugin Patch
@lynx-js/rspeedy Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 9, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 24371d41-4aec-43e5-a98b-345d5c50310d

📥 Commits

Reviewing files that changed from the base of the PR and between 965bd1f and c6f2a9e.

📒 Files selected for processing (2)
  • packages/web-platform/web-core/src/main_thread/client/element_apis/event_apis.rs
  • packages/web-platform/web-core/src/main_thread/client/element_apis/style_apis.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/web-platform/web-core/src/main_thread/client/element_apis/event_apis.rs
  • packages/web-platform/web-core/src/main_thread/client/element_apis/style_apis.rs

📝 Walkthrough

Walkthrough

Refactors web-core to use WeakRef for DOM references across Rust and TypeScript, updates WASM exports/signatures (adds gc() and extends create_element_common), adapts element APIs and tests to pass/deref WeakRef, and implements runtime GC that prunes dead DOM references.

Changes

Cohort / File(s) Summary
Release Metadata
\.changeset/refactor-weakref-webcore.md
Adds a changeset patch for @lynx-js/web-core documenting a WeakRef/WASM-binding refactor.
WASM Type Definitions
packages/web-platform/web-core/binary/client/client.d.ts, packages/web-platform/web-core/binary/client/client_bg.wasm.d.ts, packages/web-platform/web-core/binary/client_legacy/client.d.ts, packages/web-platform/web-core/binary/client_legacy/client_bg.wasm.d.ts
Extended mainthreadwasmcontext_create_element_common arity (extra param for WeakRef), get_dom_by_unique_id now returns a WeakRef, and mainthreadwasmcontext_gc export added.
Rust JS Bindings
packages/web-platform/web-core/src/js_binding/mts_js_binding.rs
Bindings switched to accept js_sys::WeakRef, some bindings marked catch and now return Result<..., JsValue>; added setAttribute/removeAttribute.
Rust Element APIs
packages/web-platform/web-core/src/main_thread/client/element_apis/event_apis.rs, packages/web-platform/web-core/src/main_thread/client/element_apis/style_apis.rs
Calls updated to use mts_binding WeakRef-based methods; enable/disable results are now checked and logged; style ops routed through binding with error propagation.
Rust Runtime Core
packages/web-platform/web-core/src/main_thread/client/main_thread_context.rs
unique_id_to_dom_map stores js_sys::WeakRef; create_element_common/get_dom_by_unique_id signatures updated; gc() implemented to prune dead refs and clear related maps.
TypeScript Binding Types
packages/web-platform/web-core/ts/types/IMtsBinding.ts
RustMainthreadContextBinding signatures updated to take WeakRef<HTMLElement> for DOM ops; added setAttribute and removeAttribute.
TypeScript Implementation
packages/web-platform/web-core/ts/client/mainthread/elementAPIs/WASMJSBinding.ts, packages/web-platform/web-core/ts/client/mainthread/elementAPIs/createElementAPI.ts
JS bindings now accept WeakRef<HTMLElement> and dereference via deref(); calls to create_element_common now pass new WeakRef(dom); wasmContext.gc() invoked during element-tree flush; deref guards added for class/attribute/event flows.
Tests
packages/web-platform/web-core/tests/element-apis.spec.ts
Tests updated to pass new WeakRef(element) and assert expect.any(WeakRef) for binding calls.
WASM loader typing
packages/web-platform/web-core/ts/client/wasm.ts
Tightened wasmLoaded tuple typing via a type-only import/cast to WasmInstanceType.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • Sherry-hue
  • colinaaa

Poem

🐇 I nibble at refs, light as air,
I tuck dead nodes in burrows spare,
Weak hops, GC hums, maps shrink tight,
I deref the leaves at morning light,
Memory tidy — rabbit delight! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

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.
Title check ❓ Inconclusive The title is truncated and does not fully convey the changeset's main objective regarding WeakRef usage and memory management improvements. Complete the title to clearly state the primary change, e.g., 'refactor: use WeakRef in element APIs and WASM bindings to improve memory management' or similar.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
4710 1 4709 123
View the top 3 failed test(s) by shortest run time
packages/rspeedy/plugin-react/test/config.test.ts > Config > transform configs > defineDCE should correctly eliminate dead code for compilation macros
Stack Traces | 0.581s run time
AssertionError: Build output should exist at .../test/dist/.rspeedy/defineDCE/main-thread.js
 ❯ test/config.test.ts:2107:16
packages/rspeedy/plugin-qrcode/test/index.test.ts > Plugins - Terminal > schema > custom schema object
Stack Traces | 1.07s run time
Error: Matcher did not succeed in time.
 ❯ test/index.test.ts:185:53

Caused by: Caused by: Caused by: AssertionError: expected "renderUnicodeCompact" to be called 2 times, but got 1 times
packages/rspeedy/plugin-qrcode/test/index.test.ts > Plugins - Terminal > schema > select between entries
Stack Traces | 1.24s run time
Error: Matcher did not succeed in time.
 ❯ test/index.test.ts:262:53

Caused by: Caused by: Caused by: AssertionError: expected "renderUnicodeCompact" to be called 2 times, but got 1 times
tests/lynx.spec.ts > kitten-lynx testing framework > can click
Stack Traces | 5.04s run time
Error: No response found for deviceId: emulator-5554 port: 8901
 ❯ Connector.#sendMessageWithTransport ../...../devtool-connector/src/index.ts:442:11
 ❯ Connector.sendCDPMessage ../...../devtool-connector/src/index.ts:215:12
 ❯ CDPChannel.send src/CDPChannel.ts:158:12
 ❯ ElementNode.tap src/ElementNode.ts:93:5
 ❯ tests/lynx.spec.ts:90:5
tests/lynx.spec.ts > kitten-lynx testing framework
Stack Traces | 11.3s run time
Error: No response found for deviceId: emulator-5554 port: 8901
 ❯ Connector.#sendMessageWithTransport ../...../devtool-connector/src/index.ts:442:11
 ❯ Connector.setGlobalSwitch ../...../devtool-connector/src/index.ts:294:5
 ❯ Function.connect src/Lynx.ts:163:5
 ❯ tests/lynx.spec.ts:46:12
tests/lynx.spec.ts > kitten-lynx testing framework > can take a screenshot
Stack Traces | 50s run time
Error: Test timed out in 50000ms.
If this is a long-running test, pass a timeout value as the last argument or configure it globally with "testTimeout".
 ❯ tests/lynx.spec.ts:100:3

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Copy link
Copy Markdown
Contributor

@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

Caution

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

⚠️ Outside diff range comments (1)
packages/web-platform/web-core/src/main_thread/client/main_thread_context.rs (1)

75-160: ⚠️ Potential issue | 🟠 Major

Add JS-side coverage for the WeakRef lifecycle and gc() cleanup.

This changes src/main_thread behavior across the JS/WASM boundary, but the PR does not include the corresponding element-apis.spec.ts coverage for lookup/deref and stale-entry cleanup. Please add tests for the new get_dom_by_unique_id()?.deref() flow and for gc() clearing dead handles, preferably with the WASMJSBinding.ts mock.

As per coding guidelines, packages/web-platform/web-core/src/main_thread/**/*.rs: "When modifying src/main_thread, ALWAYS add corresponding tests in tests/element-apis.spec.ts to verify the JS-side behavior"; based on learnings, use WASMJSBinding.ts to mock the Wasm binding in those tests.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/web-platform/web-core/src/main_thread/client/main_thread_context.rs`
around lines 75 - 160, Add JS-side tests in tests/element-apis.spec.ts to cover
the new WeakRef lifecycle and gc() cleanup: write tests that call the
wasm-exposed paths which use create_element_common to register elements, assert
get_dom_by_unique_id()?.deref() returns the mocked HtmlElement when alive (use
WASMJSBinding.ts to mock the Wasm binding and supply js_sys.WeakRef-like
behavior), then simulate the element going out of scope / being collected and
call gc() via the wasm binding and assert the weak ref is gone and the unique_id
entry in the JS-visible maps is cleared; reference the exported methods that
drive these flows (create_element_common behavior leading to
get_dom_by_unique_id and gc) so the tests exercise the lookup/deref and
stale-entry cleanup code paths.
🧹 Nitpick comments (2)
.changeset/refactor-weakref-webcore.md (1)

5-5: Consider improving the description grammar.

The phrase "with WeakRef" is grammatically awkward. Consider rephrasing to:

  • "refactor: use WeakRef in element APIs and WASM bindings to improve memory management"
  • "refactor: introduce WeakRef in element APIs and WASM bindings to improve memory management"
✏️ Suggested wording improvement
-refactor: with WeakRef in element APIs and WASM bindings to improve memory management.
+refactor: use WeakRef in element APIs and WASM bindings to improve memory management
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.changeset/refactor-weakref-webcore.md at line 5, Update the changeset title
phrase "refactor: with WeakRef in element APIs and WASM bindings to improve
memory management" to a grammatically correct form; edit the string in
.changeset/refactor-weakref-webcore.md replacing the awkward "with WeakRef" with
one of the suggested alternatives such as "refactor: use WeakRef in element APIs
and WASM bindings to improve memory management" or "refactor: introduce WeakRef
in element APIs and WASM bindings to improve memory management" so the commit
message reads clearly and consistently.
packages/web-platform/web-core/src/main_thread/client/element_apis/event_apis.rs (1)

60-72: Silently ignoring Result may hide binding errors.

The let _ = ... pattern explicitly discards errors from enable_element_event and disable_element_event. While this prevents panics, it could hide issues when the WeakRef has been garbage collected or when there are binding failures.

Consider logging these errors at debug level for troubleshooting, or at minimum documenting why errors are intentionally ignored here.

♻️ Optional: Log errors at debug level
     if should_enable {
       if let Some(element) = self.unique_id_to_dom_map.get(&unique_id) {
-        let _ = self
+        if let Err(e) = self
           .mts_binding
-          .enable_element_event(element, event_name_str);
+          .enable_element_event(element, event_name_str) {
+          // WeakRef may have been collected - this is expected during cleanup
+          web_sys::console::debug_1(&e);
+        }
       }
     } else if should_disable {
       if let Some(element) = self.unique_id_to_dom_map.get(&unique_id) {
-        let _ = self
+        if let Err(e) = self
           .mts_binding
-          .disable_element_event(element, event_name_str);
+          .disable_element_event(element, event_name_str) {
+          web_sys::console::debug_1(&e);
+        }
       }
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/web-platform/web-core/src/main_thread/client/element_apis/event_apis.rs`
around lines 60 - 72, The code is discarding the Result from calls to
mts_binding.enable_element_event and disable_element_event, hiding binding
errors; update the branches where self.unique_id_to_dom_map.get(&unique_id) is
Some(...) so that the returned Result is inspected and any Err is logged (e.g.,
via tracing::debug! or the crate's logger) with context including unique_id and
event_name_str; ensure you call logging in both the enable path
(mts_binding.enable_element_event) and disable path
(mts_binding.disable_element_event) so failures (like a dropped WeakRef or
binding error) are visible while preserving current control flow.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@packages/web-platform/web-core/src/main_thread/client/main_thread_context.rs`:
- Around line 117-119: The get_dom_by_unique_id() Rust binding now returns a
js_sys::WeakRef, but createElementAPI.ts still treats it as an HTMLElement;
update the two callers to dereference the weak handle before using it: at the
call that passes the value to markExposureRelatedElementByUniqueId(), call
.deref() and validate non-null before passing, and at the call that uses
element.insertBefore(), deref the WeakRef to a Node and check for null;
alternatively replace direct get_dom_by_unique_id() usage with the existing
getElementByUniqueId() wrapper in WASMJSBinding.ts which already performs the
dereference and null-check.

---

Outside diff comments:
In
`@packages/web-platform/web-core/src/main_thread/client/main_thread_context.rs`:
- Around line 75-160: Add JS-side tests in tests/element-apis.spec.ts to cover
the new WeakRef lifecycle and gc() cleanup: write tests that call the
wasm-exposed paths which use create_element_common to register elements, assert
get_dom_by_unique_id()?.deref() returns the mocked HtmlElement when alive (use
WASMJSBinding.ts to mock the Wasm binding and supply js_sys.WeakRef-like
behavior), then simulate the element going out of scope / being collected and
call gc() via the wasm binding and assert the weak ref is gone and the unique_id
entry in the JS-visible maps is cleared; reference the exported methods that
drive these flows (create_element_common behavior leading to
get_dom_by_unique_id and gc) so the tests exercise the lookup/deref and
stale-entry cleanup code paths.

---

Nitpick comments:
In @.changeset/refactor-weakref-webcore.md:
- Line 5: Update the changeset title phrase "refactor: with WeakRef in element
APIs and WASM bindings to improve memory management" to a grammatically correct
form; edit the string in .changeset/refactor-weakref-webcore.md replacing the
awkward "with WeakRef" with one of the suggested alternatives such as "refactor:
use WeakRef in element APIs and WASM bindings to improve memory management" or
"refactor: introduce WeakRef in element APIs and WASM bindings to improve memory
management" so the commit message reads clearly and consistently.

In
`@packages/web-platform/web-core/src/main_thread/client/element_apis/event_apis.rs`:
- Around line 60-72: The code is discarding the Result from calls to
mts_binding.enable_element_event and disable_element_event, hiding binding
errors; update the branches where self.unique_id_to_dom_map.get(&unique_id) is
Some(...) so that the returned Result is inspected and any Err is logged (e.g.,
via tracing::debug! or the crate's logger) with context including unique_id and
event_name_str; ensure you call logging in both the enable path
(mts_binding.enable_element_event) and disable path
(mts_binding.disable_element_event) so failures (like a dropped WeakRef or
binding error) are visible while preserving current control flow.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5aa3ad09-ee11-4f06-98ab-ee5c996f0012

📥 Commits

Reviewing files that changed from the base of the PR and between 59d11b2 and 0f0b1dd.

📒 Files selected for processing (13)
  • .changeset/refactor-weakref-webcore.md
  • packages/web-platform/web-core/binary/client/client.d.ts
  • packages/web-platform/web-core/binary/client/client_bg.wasm.d.ts
  • packages/web-platform/web-core/binary/client_legacy/client.d.ts
  • packages/web-platform/web-core/binary/client_legacy/client_bg.wasm.d.ts
  • packages/web-platform/web-core/src/js_binding/mts_js_binding.rs
  • packages/web-platform/web-core/src/main_thread/client/element_apis/event_apis.rs
  • packages/web-platform/web-core/src/main_thread/client/element_apis/style_apis.rs
  • packages/web-platform/web-core/src/main_thread/client/main_thread_context.rs
  • packages/web-platform/web-core/tests/element-apis.spec.ts
  • packages/web-platform/web-core/ts/client/mainthread/elementAPIs/WASMJSBinding.ts
  • packages/web-platform/web-core/ts/client/mainthread/elementAPIs/createElementAPI.ts
  • packages/web-platform/web-core/ts/types/IMtsBinding.ts

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 9, 2026

Merging this PR will degrade performance by 14.57%

❌ 1 regressed benchmark
✅ 71 untouched benchmarks
⏩ 21 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
transform 1000 view elements 40.4 ms 47.3 ms -14.57%

Comparing PupilTong:p/hw/use-weak-ref-dom-handle (965bd1f) with main (5151fcf)

Open in CodSpeed

Footnotes

  1. 21 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@relativeci
Copy link
Copy Markdown

relativeci bot commented Apr 9, 2026

React External

#301 Bundle Size — 590.13KiB (0%).

965bd1f(current) vs 5151fcf main#294(baseline)

Bundle metrics  no changes
                 Current
#301
     Baseline
#294
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 17 17
No change  Duplicate Modules 5 5
No change  Duplicate Code 8.59% 8.59%
No change  Packages 0 0
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#301
     Baseline
#294
No change  Other 590.13KiB 590.13KiB

Bundle analysis reportBranch PupilTong:p/hw/use-weak-ref-dom-...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci bot commented Apr 9, 2026

Web Explorer

#8757 Bundle Size — 748.66KiB (+0.7%).

965bd1f(current) vs 5151fcf main#8751(baseline)

Bundle metrics  Change 3 changes Regression 1 regression
                 Current
#8757
     Baseline
#8751
Regression  Initial JS 44.27KiB(+1.04%) 43.82KiB
No change  Initial CSS 2.16KiB 2.16KiB
Change  Cache Invalidation 48.89% 28.41%
No change  Chunks 8 8
No change  Assets 10 10
No change  Modules 149 149
No change  Duplicate Modules 11 11
Change  Duplicate Code 35.02%(+0.17%) 34.96%
No change  Packages 3 3
No change  Duplicate Packages 0 0
Bundle size by type  Change 2 changes Regression 2 regressions
                 Current
#8757
     Baseline
#8751
Regression  Other 401.63KiB (+0.87%) 398.15KiB
Regression  JS 344.87KiB (+0.5%) 343.13KiB
No change  CSS 2.16KiB 2.16KiB

Bundle analysis reportBranch PupilTong:p/hw/use-weak-ref-dom-...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci bot commented Apr 9, 2026

React MTF Example

#316 Bundle Size — 206.11KiB (0%).

965bd1f(current) vs 5151fcf main#309(baseline)

Bundle metrics  no changes
                 Current
#316
     Baseline
#309
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 173 173
No change  Duplicate Modules 67 67
No change  Duplicate Code 45.76% 45.76%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#316
     Baseline
#309
No change  IMG 111.23KiB 111.23KiB
No change  Other 94.88KiB 94.88KiB

Bundle analysis reportBranch PupilTong:p/hw/use-weak-ref-dom-...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci bot commented Apr 9, 2026

React Example

#7183 Bundle Size — 236.82KiB (0%).

965bd1f(current) vs 5151fcf main#7176(baseline)

Bundle metrics  no changes
                 Current
#7183
     Baseline
#7176
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 179 179
No change  Duplicate Modules 70 70
No change  Duplicate Code 46.1% 46.1%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#7183
     Baseline
#7176
No change  IMG 145.76KiB 145.76KiB
No change  Other 91.06KiB 91.06KiB

Bundle analysis reportBranch PupilTong:p/hw/use-weak-ref-dom-...Project dashboard


Generated by RelativeCIDocumentationReport issue

Sherry-hue
Sherry-hue previously approved these changes Apr 10, 2026
Copy link
Copy Markdown
Contributor

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/web-platform/web-core/src/js_binding/mts_js_binding.rs`:
- Around line 39-72: The new wasm_bindgen methods (enable_element_event,
disable_element_event, get_class_name_list, set_attribute, remove_attribute) now
return Result<..., JsValue> but callers like add_cross_thread_event in
event_apis.rs and set_css_id in style_apis.rs currently discard results with let
_ = ..., causing JS/DOM errors to be swallowed; update those call sites to
handle the Result by either propagating the error (use the ? operator or convert
JsValue into the function's error type and return Err) in functions that already
return Result, or at minimum log the Err (convert JsValue to JsError/Debug)
before continuing, ensuring you address every occurrence where
enable_element_event/disable_element_event/get_class_name_list/set_attribute/remove_attribute
are discarded rather than handled.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9fa4ff99-96d2-4c27-bd49-71c35b522f8b

📥 Commits

Reviewing files that changed from the base of the PR and between 8c57025 and 965bd1f.

📒 Files selected for processing (14)
  • .changeset/refactor-weakref-webcore.md
  • packages/web-platform/web-core/binary/client/client.d.ts
  • packages/web-platform/web-core/binary/client/client_bg.wasm.d.ts
  • packages/web-platform/web-core/binary/client_legacy/client.d.ts
  • packages/web-platform/web-core/binary/client_legacy/client_bg.wasm.d.ts
  • packages/web-platform/web-core/src/js_binding/mts_js_binding.rs
  • packages/web-platform/web-core/src/main_thread/client/element_apis/event_apis.rs
  • packages/web-platform/web-core/src/main_thread/client/element_apis/style_apis.rs
  • packages/web-platform/web-core/src/main_thread/client/main_thread_context.rs
  • packages/web-platform/web-core/tests/element-apis.spec.ts
  • packages/web-platform/web-core/ts/client/mainthread/elementAPIs/WASMJSBinding.ts
  • packages/web-platform/web-core/ts/client/mainthread/elementAPIs/createElementAPI.ts
  • packages/web-platform/web-core/ts/client/wasm.ts
  • packages/web-platform/web-core/ts/types/IMtsBinding.ts
✅ Files skipped from review due to trivial changes (2)
  • .changeset/refactor-weakref-webcore.md
  • packages/web-platform/web-core/tests/element-apis.spec.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • packages/web-platform/web-core/src/main_thread/client/element_apis/event_apis.rs
  • packages/web-platform/web-core/ts/client/wasm.ts
  • packages/web-platform/web-core/src/main_thread/client/element_apis/style_apis.rs
  • packages/web-platform/web-core/binary/client_legacy/client_bg.wasm.d.ts
  • packages/web-platform/web-core/binary/client/client_bg.wasm.d.ts
  • packages/web-platform/web-core/binary/client_legacy/client.d.ts

@PupilTong PupilTong requested a review from Sherry-hue April 10, 2026 06:10
@PupilTong PupilTong force-pushed the p/hw/use-weak-ref-dom-handle branch from c6f2a9e to 965bd1f Compare April 10, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants