Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Referencing an outside variable from a closure in spawn.stderr.on causes jxcore to fail #13

Closed
yaronyg opened this issue Jul 27, 2016 · 0 comments
Assignees

Comments

@yaronyg
Copy link
Member

yaronyg commented Jul 27, 2016

function childProcessExecPromise(commandString, currentWorkingDirectory) {
  return new Promise(function (resolve, reject) {
    var commandSplit = commandString.split(' ');
    var command = commandSplit.shift();
    var stdErrData = false;
    var theProcess = spawn(command, commandSplit,
                            { cwd: currentWorkingDirectory});
    theProcess.stdout.on('data', function (data) {
      console.log('' + data);
    });
    theProcess.stderr.on('data', function (data) {
      //stdErrData = true;
      console.log('' + data);
    });
    theProcess.on('close', function (code) {
      if (code !== 0) {
        return reject(code);
      }
      if (stdErrData) {
        return reject(-1);
      }
      return resolve();
    });
  });

If I uncomment stdErrData = true; then JXcore faills.

@yaronyg yaronyg removed the 1 - Ready label Oct 6, 2016
enricogior pushed a commit that referenced this issue Mar 4, 2017
Fixes the following assertion on slow systems, like our ARM buildbot:

    $ out/Debug/node test/simple/test-timers-unref.js
    node: ../src/async-wrap-inl.h:101: v8::Handle<v8::Value>
    node::AsyncWrap::MakeCallback(uint32_t, int,
    v8::Handle<v8::Value>*): Assertion `cb_v->IsFunction()' failed.
    Aborted

The reason it only manifests on slow systems is that the test starts
a 1 ms interval timer, then defers timer.unref.bind({}) to the next
tick.  On fast systems, the test completes in under a millisecond,
before the callback is called.

This commit makes timer.unref() check that the receiver actually has
a timeout callback property.

Fixes #13.

PR-URL: nodejs/node#165
Reviewed-By: Rod Vagg <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants