GeezerVison is showing github.com — fix(runtime): keep clone-only message reads read-only, and see an uncloneable brand created mid-clone by edusperoni · Pull Request #2088 · NativeScript/android
Conversation
edusperoni
commented
Nov 5, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Supersedes #2064, which GitHub closed when its base branch (feat/worker-threads) was deleted at the #2043 squash. The commit is @adrian-niculescu's, replayed onto main with authorship kept. The only conflict was the adjacent spec additions in testMessaging.js.
An object marked with markAsUncloneable from a getter, during the clone that reaches it, is cloned instead of throwing DataCloneError when that is the first markAsUncloneable call in the isolate. The serializer reads the brand once, when it is constructed, and at that point the brand does not exist yet. It now picks the brand up once markAsUncloneable creates it.
Separately, SerializedValue::Deserialize cleared its transfer vectors on every read. A clone-only message is read by every BroadcastChannel receiver, and every getEnvironmentData call, with no lock, so those clears were concurrent writes to shared state, against what the comment on the consumed_ flag intends. Only the single receiver of a message with transferables writes them now.
The same fix for iOS is NativeScript/ios#490; the StructuredSerialization.cpp change matches it.
Merge after #2087. This branch is stacked on it, so until that squash lands the diff here also shows its commits. Full device suite with both applied: 1462 specs, 0 failures.
Summary by CodeRabbit
- Bug Fixes
- Message delivery now preserves
undefined payloads across message ports, broadcast channels, and workers, while constructed message events retain the expected default of null.
- Message deserialization errors now provide the relevant exception as event data, falling back to
null when unavailable.
- Improved handling of uncloneable objects detected during serialization and messages containing transferables.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 5, 2026
coderabbitai
Bot
commented
Nov 5, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

Warning
Review limit reached
You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.
Next included review available in 41 minutes.
Check out review usage here.
View limit details
-
Limit details: You’ve used all 4 included reviews currently available.
Learn how review limits work.
Review configuration:
Run configuration
-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
ba811c2e-54b4-4a5e-8ddf-099b0e4c1a62
Commits
-
Reviewing files that changed from the base of the PR and between 9beb920 and 4088462.
Files selected for processing: 4
-
test-app/app/src/main/assets/app/tests/messaging/uncloneableAfterGetterWorker.js
test-app/app/src/main/assets/app/tests/messaging/uncloneableInGetterWorker.js
test-app/app/src/main/assets/app/tests/testMessaging.js
test-app/runtime/src/main/cpp/StructuredSerialization.cpp
Walkthrough
-
The changes add a message-event factory that preserves undefined data, adjust deserialization and message-error handling, and update structured serialization behavior. New messaging tests cover payload values, worker responses, and cloning an object marked uncloneable during serialization.
Changes: Messaging runtime behavior
| Layer / File(s) |
Summary |
Create and dispatch message events test-app/runtime/src/main/cpp/js/message-event.js, test-app/runtime/src/main/cpp/js/{message-channel,broadcast-channel,node-worker-threads,worker-events}.js |
A new createMessageEvent factory assigns data directly after constructing the event. Message-delivery paths use the factory with the message type, data, and ports. |
Serialization and message errors test-app/runtime/src/main/cpp/StructuredSerialization.cpp, test-app/runtime/src/main/cpp/Messaging.cpp, test-app/runtime/src/main/cpp/WorkerEvents.{cpp,h} |
Structured serialization rechecks the uncloneable brand and clears transferred buffer and port lists only when the message has transferables. Deserialization failures use the caught exception as messageerror data, or null if no exception is available or the exception is undefined. |
Validate message payloads and cloning test-app/app/src/main/assets/app/tests/testMessaging.js, test-app/app/src/main/assets/app/tests/messaging/* |
Tests cover falsy and undefined payloads across messaging APIs, MessageEvent defaults, worker responses, and a DataCloneError when an object becomes uncloneable during cloning. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Sequence Diagram(s)
sequenceDiagram
participant MessagePort
participant emitMessage
participant createMessageEvent
participant Listener
MessagePort->>emitMessage: deliver message type, data, and ports
emitMessage->>createMessageEvent: create event
createMessageEvent-->>emitMessage: return event with data assigned directly
emitMessage->>Listener: dispatch event
Loading
Possibly related PRs
Merge Risk: Minimal · previous review 9beb9
-
The changes preserve message payloads and avoid writes during clone-only reads. No concrete merge-blocking issue remains.
Pre-merge checks: 4 · 1
-
Failed checks: 1 warning
| Check name |
Status |
Explanation |
Resolution |
| Docstring Coverage |
 |
Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… |
Write docstrings for the functions missing them to satisfy the coverage threshold. |
Passed checks: 4 passed
-
| Check name |
Status |
Explanation |
| Description Check |
 |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
 |
The title names the runtime fix and both behaviors the changeset addresses: clone-only message reads stay read-only (StructuredSerialization.cpp only clears transfer lists on the single-receiver path)… |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
Full details: Title check
-
Explanation
The title names the runtime fix and both behaviors the changeset addresses: clone-only message reads stay read-only (StructuredSerialization.cpp only clears transfer lists on the single-receiver path) and the serializer now recognizes an uncloneable brand created mid-clone (IsHostObject lazy recheck). The title is specific and matches the main changes. It is long, at 101 characters and 13 words, but it stays on topic and is not vague.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 11 functions across 13 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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
-
A rabbit sends a message through the night, “Undefined” arrives, preserved just right. The ports stay ready, clone checks are keen, Errors carry data, clearly seen. I thump my paws: the tests all gleam!
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…loneable brand created mid-clone
A clone-only message is read concurrently by every BroadcastChannel receiver and every getEnvironmentData call, and deserializing it cleared its transfer vectors, a write. Only the single receiver of a message with transferables writes them now.
The serializer cached the uncloneable brand when it was created, so the first markAsUncloneable call in an isolate, made by a getter in the graph being written, went unseen and the marked object was cloned. It now picks the brand up once it exists.
…ostObject
V8 calls the serializer delegate's IsHostObject inside a HandleScope that
WriteJSReceiver opens per object. When a getter created the isolate's first
uncloneable brand mid-clone, IsHostObject cached the brand's Local in the
delegate, and every later object in the same clone checked HasPrivate against
a handle whose scope had already closed: a marked object reached after that
getter was cloned instead of rejected. A late lookup now stays local to the
call; the brand cached at construction lives in Serialize's own scope and is
still used when it exists.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|