Skip to content

fix(runtime): deliver a posted undefined as undefined, not null - #2063

Draft
adrian-niculescu wants to merge 1 commit into
NativeScript:feat/worker-threadsfrom
adrian-niculescu:fix/message-event-undefined-data
Draft

adrian-niculescu wants to merge 1 commit into
NativeScript:feat/worker-threadsfrom
adrian-niculescu:fix/message-event-undefined-data

Conversation

@adrian-niculescu

Copy link
Copy Markdown
Contributor

postMessage(undefined) arrives as null everywhere a message is delivered: a MessagePort, a BroadcastChannel, a Worker and its global scope, and a node:worker_threads parentPort. Node and browsers deliver undefined.

Every delivery path builds its event with new MessageEvent(type, { data, ports }), and the constructor's init dictionary turns an undefined data into null, as Web IDL requires. Delivery now goes through an internal createMessageEvent that stores the payload as given, the same fix as NativeScript/ios#477. The native messageerror paths pass null instead of undefined, so that event keeps its default. A worker's messageerror now carries the deserialization failure as its data, as a port's already does and as NativeScript/ios#489 does on iOS.

Stacked on #2043. The new specs in testMessaging.js fail on that branch and pass with this change, and the full device suite passes.

Every delivery path built its MessageEvent through the public constructor, whose init dictionary turns an undefined data into null. Delivery now goes through an internal factory that stores the payload as given. The native messageerror paths pass null so that event keeps its default data, and a worker's messageerror carries the deserialization failure as its data, as a port's already does.
@coderabbitai

coderabbitai Bot commented Oct 6, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autopilot · 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

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

This branch has not been deployed

No deployments
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