Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
Revert "[7.7] [kbn/optimizer] poll parent process to avoid zombie pro…
Browse files Browse the repository at this point in the history
…cesses (elastic#67059) (elastic#67119)"

This reverts commit e6a5a9d.
  • Loading branch information
spalger committed May 22, 2020
1 parent 59eaa3e commit 8f34bf1
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 361 deletions.
1 change: 0 additions & 1 deletion packages/kbn-optimizer/src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export * from './bundle';
export * from './bundle_cache';
export * from './worker_config';
export * from './worker_messages';
export * from './parent_messages';
export * from './compiler_messages';
export * from './ts_helpers';
export * from './rxjs_helpers';
Expand Down
33 changes: 0 additions & 33 deletions packages/kbn-optimizer/src/common/parent_messages.ts

This file was deleted.

19 changes: 1 addition & 18 deletions packages/kbn-optimizer/src/common/worker_messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,13 @@ import {
CompilerErrorMsg,
} from './compiler_messages';

export type InternalWorkerMsg =
| WorkerPingMsg
export type WorkerMsg =
| CompilerRunningMsg
| CompilerIssueMsg
| CompilerSuccessMsg
| CompilerErrorMsg
| WorkerErrorMsg;

// ping messages are internal, they don't apper in public message streams
export type WorkerMsg = Exclude<InternalWorkerMsg, WorkerPingMsg>;

/**
* Message sent when the worker encounters an error that it can't
* recover from, no more messages will be sent and the worker
Expand All @@ -46,10 +42,6 @@ export interface WorkerErrorMsg {
errorStack?: string;
}

export interface WorkerPingMsg {
type: 'ping';
}

const WORKER_STATE_TYPES: ReadonlyArray<WorkerMsg['type']> = [
'running',
'compiler issue',
Expand All @@ -58,19 +50,10 @@ const WORKER_STATE_TYPES: ReadonlyArray<WorkerMsg['type']> = [
'worker error',
];

export const isWorkerPing = (value: any): value is WorkerPingMsg =>
typeof value === 'object' && value && value.type === 'ping';

export const isWorkerMsg = (value: any): value is WorkerMsg =>
typeof value === 'object' && value && WORKER_STATE_TYPES.includes(value.type);

export class WorkerMsgs {
ping(): WorkerPingMsg {
return {
type: 'ping',
};
}

error(error: Error): WorkerErrorMsg {
return {
type: 'worker error',
Expand Down
16 changes: 2 additions & 14 deletions packages/kbn-optimizer/src/optimizer/observe_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ import { Readable } from 'stream';
import { inspect } from 'util';

import * as Rx from 'rxjs';
import { map, filter, takeUntil } from 'rxjs/operators';
import { map, takeUntil } from 'rxjs/operators';

import { isWorkerMsg, isWorkerPing, WorkerConfig, WorkerMsg, Bundle, ParentMsgs } from '../common';
import { isWorkerMsg, WorkerConfig, WorkerMsg, Bundle } from '../common';

import { OptimizerConfig } from './optimizer_config';

const parentMsgs = new ParentMsgs();

export interface WorkerStdio {
type: 'worker stdio';
stream: 'stdout' | 'stderr';
Expand Down Expand Up @@ -148,16 +146,6 @@ export function observeWorker(
observeStdio$(proc.stderr, 'stderr'),
Rx.fromEvent<[unknown]>(proc, 'message')
.pipe(
// filter out ping messages so they don't end up in the general message stream
filter(([msg]) => {
if (!isWorkerPing(msg)) {
return true;
}

proc.send(parentMsgs.pong());
return false;
}),

// validate the messages from the process
map(([msg]) => {
if (!isWorkerMsg(msg)) {
Expand Down
178 changes: 0 additions & 178 deletions packages/kbn-optimizer/src/worker/observe_parent_offline.test.ts

This file was deleted.

Loading

0 comments on commit 8f34bf1

Please sign in to comment.