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 fileTake it
Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
line 1why, one step back1import {checkIpcMaxBuffer} from '../io/max-buffer.js';Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360
line 2why, one step back2import {shouldLogIpc, logIpcOutput} from '../verbose/ipc.js';Refactor `verbose` logic (#1126)ehmickybefore adoptionf9f1199
line 3why, one step back3import {getFdSpecificValue} from '../arguments/specific.js';Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 4–6why, one step back4import {loopOnMessages} from './get-each.js';56// Iterate through IPC messages sent by the subprocessRename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360
line 7why, one step back7export const waitForIpcOutput = async ({Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 8–11why, one step back8 subprocess,9 buffer: bufferArray,10 maxBuffer: maxBufferArray,11 ipc,Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360
line 12why, one step back12 ipcOutput,Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 13–15why, one step back13 verboseInfo,14}) => {15 if (!ipc) {Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360
line 16why, one step back16 return ipcOutput;Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 17–19why, one step back17 }1819 const isVerbose = shouldLogIpc(verboseInfo);Refactor `verbose` logic (#1126)ehmickybefore adoptionf9f1199
lines 20–21why, one step back20 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 back22 // A throwing `verbose` function must not prevent the following messages from being buffered23 const logErrors = [];Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 24–26why, one step back2425 for await (const message of loopOnMessages({26 anyProcess: subprocess,Refactor reference counting with IPC (#1089)ehmickybefore adoption18e607c
line 27why, one step back27 channel: subprocess.channel,Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 28–30why, one step back28 isSubprocess: false,29 ipc,30 shouldAwait: false,Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6
line 31why, one step back31 reference: true,Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 32–33why, one step back32 })) {33 if (buffer) {Fix `maxBuffer` being ignored or wrongly appliedSindre Sorhusbefore adoption9547e51
line 34why, one step back34 checkIpcMaxBuffer(ipcOutput, maxBuffer);Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360
line 35why, one step back35 ipcOutput.push(message);Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 36–38why, one step back36 }3738 if (isVerbose) {Fix `verbose` discarding IPC messages when its function throwsSindre Sorhusbefore adoptionb548d8b
lines 39–43why, one step back39 try {40 logIpcOutput(message, verboseInfo);41 } catch (error) {42 logErrors.push(error);43 }Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
line 44why, one step back44 }Fix `verbose` discarding IPC messages when its function throwsSindre Sorhusbefore adoptionb548d8b
lines 45–48why, one step back45 }4647 if (logErrors.length > 0) {48 throw logErrors[0];Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 49–50why, one step back49 }50Improve `buffer: false` behavior with IPC (#1092)ehmickybefore adoption76d637a
lines 51–55why, one step back51 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 back56 return ipcOutput;Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
line 57why, one step back57};