Skip to content

runInContext breaks node process #13464

@hsiliev

Description

@hsiliev
  • Version:
    • 6.10.3
    • 7.10.0
  • Platform:
    • Darwin SOFM33780462A 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64
    • Linux ip-10-0-0-11 3.13.0-74-generic Is it io.js, IO.js, or something else? #118-Ubuntu SMP Thu Dec 17 22:52:10 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: vm

When the following code is executed:

"use strict";

const vm = require('vm');

let i = 0;

while(true) {

  try {
    const context = {};
    vm.createContext(context);
    vm.runInContext(
      '"use strict"; ( 1 + 1 )',
      context,
      { timeout: 1 }
    );
  } catch (e) {
    console.log('Exception: %j', e);
  }

  console.log('Attempt: %d', ++i);
}

Node 6 & node 7 on both Mac & Linux, it bails out with exit code 0 , instead of looping endlessly. We get 2 to max 80 iterations without any exception logged.

Interesting is also the fact that under high load in containerized environment (Cloud Foundry's Garden) the context execution blocks. Even with 1000 ms timeout it never returns or throws exception. We observed a call hanging for > 48 hours.

With node 8 the code works correctly and we get the expected endless loop with occasional exceptions due to the extremely low timeout.

Metadata

Metadata

Assignees

No one assigned

    Labels

    vmIssues and PRs related to the vm subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions