Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

worker: make MessagePort constructor non-callable #28032

Closed

Conversation

Copy link
Member

@addaleax addaleax commented Jun 2, 2019

Refactor the C++ code for creating MessagePorts to skip calling the
constructor and instead directly instantiating the InstanceTemplate,
and always throw an error from the MessagePort constructor.

This aligns behaviour with the web, and creating single MessagePorts
does not make sense anyway.

This is technically a breaking change and I’d be happy to split out the added throw into a separate PR out of caution, if anybody considers that a good idea.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@addaleax addaleax added the worker label Jun 2, 2019
Trott
Trott approved these changes Jun 2, 2019
Copy link
Member

@Trott Trott left a comment

LGTM if CI is green. I guess since worker_threads are still Experimental, this can technically still land as a patch in 12.x even if it is deemed semver-major. (But I'm OK if we'd rather be cautious. Fine either way.)

@BridgeAR BridgeAR added the author ready label Jun 4, 2019
test/wpt/test-url.js Outdated Show resolved Hide resolved
GetMessagePortConstructor(env, context).ToLocalChecked())
.Check();
GetMessagePortConstructorTemplate(env)
->GetFunction(context).ToLocalChecked()).Check();
Copy link
Member

@joyeecheung joyeecheung Jun 5, 2019

Choose a reason for hiding this comment

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

Can't we just use ConstructorBehavior::kThrow for this? If there is a particular reason for throwing our own style of errors I think that's worth a comment..

Copy link
Member Author

@addaleax addaleax Jun 9, 2019

Choose a reason for hiding this comment

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

@joyeecheung Yeah, it doesn’t work because that also removes the prototype property. I’m adding a comment, though.

@addaleax addaleax force-pushed the messageport-constructor-callable branch from 09d50f0 to 9902484 Compare Jun 9, 2019
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

Refactor the C++ code for creating `MessagePort`s to skip calling the
constructor and instead directly instantiating the `InstanceTemplate`,
and always throw an error from the `MessagePort` constructor.

This aligns behaviour with the web, and creating single `MessagePort`s
does not make sense anyway.
@addaleax addaleax force-pushed the messageport-constructor-callable branch from 9902484 to a28b289 Compare Jun 10, 2019
@nodejs-github-bot

This comment has been minimized.

chjj added a commit to chjj/bthreads that referenced this issue Jun 11, 2019
@Trott
Copy link
Member

@Trott Trott commented Jun 13, 2019

@Trott
Copy link
Member

@Trott Trott commented Jun 13, 2019

Landed in 0640526

@Trott Trott closed this Jun 13, 2019
Trott pushed a commit to Trott/io.js that referenced this issue Jun 13, 2019
Refactor the C++ code for creating `MessagePort`s to skip calling the
constructor and instead directly instantiating the `InstanceTemplate`,
and always throw an error from the `MessagePort` constructor.

This aligns behaviour with the web, and creating single `MessagePort`s
does not make sense anyway.

PR-URL: nodejs#28032
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
BridgeAR pushed a commit that referenced this issue Jun 17, 2019
Refactor the C++ code for creating `MessagePort`s to skip calling the
constructor and instead directly instantiating the `InstanceTemplate`,
and always throw an error from the `MessagePort` constructor.

This aligns behaviour with the web, and creating single `MessagePort`s
does not make sense anyway.

PR-URL: #28032
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@BridgeAR BridgeAR mentioned this pull request Jun 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready worker
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants