Skip to content

Commit

Permalink
Remove "process already captured" errors.
Browse files Browse the repository at this point in the history
This has been a very annoying source of CI failures. If it were
technically more correct I'd say we should keep it around and attempt
to fix the underlying issue, but I do not think it is. In most cases,
we are either setting up on the same object (in which case no need to
release any existing handlers) or we are providing a custom
`MockProcess` object which really won't ever _need_ capturing.
  • Loading branch information
rwjblue committed Sep 22, 2020
1 parent d6afda6 commit 3fac7fa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
8 changes: 3 additions & 5 deletions lib/utilities/will-interrupt-process.js
Expand Up @@ -16,20 +16,19 @@ const EventEmitter = require('events');

const handlers = [];

let _process, _processCapturedLocation, windowsCtrlCTrap, originalIsRaw;
let _process, windowsCtrlCTrap, originalIsRaw;

module.exports = {
capture(outerProcess) {
if (_process) {
throw new Error(`process already captured at: \n\n${_processCapturedLocation.stack}`);
if (_process !== outerProcess) {
this.release();
}

if (outerProcess instanceof EventEmitter === false) {
throw new Error('attempt to capture bad process instance');
}

_process = outerProcess;
_processCapturedLocation = new Error();

// ember-cli and user apps have many dependencies, many of which require
// process.addListener('exit', ....) for cleanup, by default this limit for
Expand Down Expand Up @@ -63,7 +62,6 @@ module.exports = {
}

_process = null;
_processCapturedLocation = null;
},

/**
Expand Down
13 changes: 0 additions & 13 deletions tests/unit/utilities/will-interrupt-process-test.js
Expand Up @@ -20,19 +20,6 @@ describe('will interrupt process', function () {
});

describe('capture', function () {
it('throws if already captured', function () {
const mockProcess = new MockProcess();

willInterruptProcess.capture(mockProcess);
try {
willInterruptProcess.capture(mockProcess);
expect(true).to.equal(false);
} catch (e) {
expect(e.message).to.include('process already captured');
expect(e.message).to.include('will-interrupt-process-test.js');
}
});

it('throws if the process is not an EventEmitter instance', function () {
const dissallowedArgs = [null, true, '', [], {}];

Expand Down

0 comments on commit 3fac7fa

Please sign in to comment.