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

addaleax
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 Issues and PRs related to Worker support. label Jun 2, 2019
Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

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 PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 4, 2019
@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented 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

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 June 9, 2019 17:55
@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 June 10, 2019 15:31
@nodejs-github-bot

This comment has been minimized.

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

Trott commented Jun 13, 2019

@Trott
Copy link
Member

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 pull request 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 pull request 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 PRs that have at least one approval, no pending requests for changes, and a CI started. worker Issues and PRs related to Worker support.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants