Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! worker: reduce MessagePort prototype to documented API
  • Loading branch information
addaleax committed Sep 23, 2018
commit fb840e7b64c5f44f70fa0f8bf485c9ca49618ca5
10 changes: 6 additions & 4 deletions lib/internal/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ const {

const { internalBinding } = require('internal/bootstrap/loaders');
const { MessagePort, MessageChannel } = internalBinding('messaging');
const { handle_onclose } = internalBinding('symbols');
const {
handle_onclose: handleOnCloseSymbol,
oninit: onInitSymbol
} = internalBinding('symbols');
const { clearAsyncIdStack } = require('internal/async_hooks');
const { serializeError, deserializeError } = require('internal/error-serdes');
const { pathToFileURL } = require('url');
Expand All @@ -23,7 +26,6 @@ const {
Worker: WorkerImpl,
getEnvMessagePort,
threadId,
Copy link
Member

Choose a reason for hiding this comment

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

Nit: this triggers my OCD, can we make this consistent with the above destructuring assignment?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, this was leftover from addressing the previous review comment … the comma is gone now :)

Copy link
Member

Choose a reason for hiding this comment

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

Thank you.

oninit: oninit_symbol
} = internalBinding('worker');

const isMainThread = threadId === 0;
Expand Down Expand Up @@ -109,7 +111,7 @@ function oninit() {
setupPortReferencing(this, this, 'message');
}

Object.defineProperty(MessagePort.prototype, oninit_symbol, {
Object.defineProperty(MessagePort.prototype, onInitSymbol, {
enumerable: true,
writable: false,
value: oninit
Expand All @@ -126,7 +128,7 @@ function onclose() {
this.emit('close');
}

Object.defineProperty(MessagePort.prototype, handle_onclose, {
Object.defineProperty(MessagePort.prototype, handleOnCloseSymbol, {
enumerable: false,
writable: false,
value: onclose
Expand Down
4 changes: 0 additions & 4 deletions src/node_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,6 @@ void InitWorker(Local<Object> target,
thread_id_string,
Number::New(env->isolate(),
static_cast<double>(env->thread_id()))).FromJust();
Local<String> oninit_string = FIXED_ONE_BYTE_STRING(env->isolate(), "oninit");
target->Set(env->context(),
oninit_string,
env->oninit_symbol()).FromJust();
}

} // anonymous namespace
Expand Down