Skip to content
Myr

buffer-messages.js

This file

Path

lib/ipc/buffer-messages.js

57 lines · 1.3 KiB · JavaScript

Last changed by

Fix `verbose` discarding IPC messages when its function throwsSindre Sorhusbefore adoptionb548d8b

History of this file

Take it

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

line 1why, one step back
1import {checkIpcMaxBuffer} from '../io/max-buffer.js';

Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360

line 2why, one step back
2import {shouldLogIpc, logIpcOutput} from '../verbose/ipc.js';

Refactor `verbose` logic (#1126)ehmickybefore adoptionf9f1199

line 3why, one step back
3import {getFdSpecificValue} from '../arguments/specific.js';

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 4–6why, one step back
4import {loopOnMessages} from './get-each.js';
56// Iterate through IPC messages sent by the subprocess

Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360

line 7why, one step back
7export const waitForIpcOutput = async ({

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 8–11why, one step back
8 subprocess,
9 buffer: bufferArray,10 maxBuffer: maxBufferArray,11 ipc,

Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360

line 12why, one step back
12 ipcOutput,

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 13–15why, one step back
13 verboseInfo,
14}) => {15 if (!ipc) {

Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360

line 16why, one step back
16 return ipcOutput;

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 17–19why, one step back
17 }
1819 const isVerbose = shouldLogIpc(verboseInfo);

Refactor `verbose` logic (#1126)ehmickybefore adoptionf9f1199

lines 20–21why, one step back
20 const buffer = getFdSpecificValue(bufferArray, 'ipc');
21 const maxBuffer = getFdSpecificValue(maxBufferArray, 'ipc');

Fix `verbose` discarding IPC messages when its function throwsSindre Sorhusbefore adoptionb548d8b

lines 22–23why, one step back
22 // A throwing `verbose` function must not prevent the following messages from being buffered
23 const logErrors = [];

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 24–26why, one step back
24
25 for await (const message of loopOnMessages({26 anyProcess: subprocess,

Refactor reference counting with IPC (#1089)ehmickybefore adoption18e607c

line 27why, one step back
27 channel: subprocess.channel,

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 28–30why, one step back
28 isSubprocess: false,
29 ipc,30 shouldAwait: false,

Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6

line 31why, one step back
31 reference: true,

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 32–33why, one step back
32 })) {
33 if (buffer) {

Fix `maxBuffer` being ignored or wrongly appliedSindre Sorhusbefore adoption9547e51

line 34why, one step back
34 checkIpcMaxBuffer(ipcOutput, maxBuffer);

Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360

line 35why, one step back
35 ipcOutput.push(message);

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 36–38why, one step back
36 }
3738 if (isVerbose) {

Fix `verbose` discarding IPC messages when its function throwsSindre Sorhusbefore adoptionb548d8b

lines 39–43why, one step back
39 try {
40 logIpcOutput(message, verboseInfo);41 } catch (error) {42 logErrors.push(error);43 }

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

line 44why, one step back
44 }

Fix `verbose` discarding IPC messages when its function throwsSindre Sorhusbefore adoptionb548d8b

lines 45–48why, one step back
45 }
4647 if (logErrors.length > 0) {48 throw logErrors[0];

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 49–50why, one step back
49 }
50

Improve `buffer: false` behavior with IPC (#1092)ehmickybefore adoption76d637a

lines 51–55why, one step back
51 return ipcOutput;
52};5354export const getBufferedIpcOutput = async (ipcOutputPromise, ipcOutput) => {55 await Promise.allSettled([ipcOutputPromise]);

Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360

line 56why, one step back
56 return ipcOutput;

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

line 57why, one step back
57};