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: parentPort.postMessage fails on undefined value #26122

Closed
legendecas opened this issue Feb 15, 2019 · 0 comments
Closed

worker: parentPort.postMessage fails on undefined value #26122

legendecas opened this issue Feb 15, 2019 · 0 comments

Comments

@legendecas
Copy link
Member

legendecas commented Feb 15, 2019

  • Version: 11.9.0
  • Platform: all
  • Subsystem: worker

parentPort.postMessage fails on assumption of not nil of first argument. Though it's documented as accepting any value.

internal/worker/io.js:65
  if (payload.type !== messageTypes.STDIO_WANTS_MORE_DATA)
              ^

TypeError: Cannot read property 'type' of undefined
    at MessagePort.onmessage (internal/worker/io.js:65:15)

full scripts:

const {
  Worker, isMainThread, parentPort, workerData
} = require('worker_threads')

if (isMainThread) {
    const worker = new Worker(__filename);
    worker.on('message', data => console.log('received worker data', data));
    worker.on('error', err => console.error('worker error:', error));
    worker.on('exit', (code) => {
      if (code !== 0)
        console.error(`Worker stopped with exit code ${code}`);
    })
    return
}

parentPort.postMessage(undefined)
legendecas added a commit to legendecas/node that referenced this issue Feb 17, 2019
addaleax pushed a commit that referenced this issue Feb 17, 2019
Related: #26122

PR-URL: #26123
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
addaleax pushed a commit that referenced this issue Feb 17, 2019
Related: #26122

PR-URL: #26123
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
rvagg pushed a commit that referenced this issue Feb 28, 2019
Related: #26122

PR-URL: #26123
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
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 a pull request may close this issue.

1 participant