@gajae-code/utils 0.12.10 → 0.12.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/broken-pipe.d.ts +4 -3
- package/package.json +2 -2
- package/src/broken-pipe.ts +16 -4
|
@@ -10,9 +10,10 @@ export declare function isKnownSinkPeerClosedError(error: unknown): boolean;
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function isBrokenPipeError(error: unknown): boolean;
|
|
12
12
|
/**
|
|
13
|
-
* A classifier for process-level stdout
|
|
14
|
-
* evidence is private to each factory instance, so
|
|
15
|
-
* intercepted `process.stdout.write` can mark an error
|
|
13
|
+
* A classifier for process-level stdout peer-closed errors (`EPIPE`, `EIO`,
|
|
14
|
+
* `EBADF`). Its direct-write evidence is private to each factory instance, so
|
|
15
|
+
* only the owner that intercepted `process.stdout.write` can mark an error
|
|
16
|
+
* for this classifier.
|
|
16
17
|
*/
|
|
17
18
|
export interface ProcessStdoutEpipeClassifier {
|
|
18
19
|
markDirectProcessStdoutWriteError(error: unknown): void;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@gajae-code/utils",
|
|
4
|
-
"version": "0.12.
|
|
4
|
+
"version": "0.12.12",
|
|
5
5
|
"description": "Shared utilities for pi packages",
|
|
6
6
|
"homepage": "https://gajae-code.com",
|
|
7
7
|
"author": "Yeachan-Heo",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"fmt": "biome format --write ."
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@gajae-code/natives": "0.12.
|
|
34
|
+
"@gajae-code/natives": "0.12.12",
|
|
35
35
|
"beautiful-mermaid": "^1.1.3",
|
|
36
36
|
"handlebars": "^4.7.9",
|
|
37
37
|
"winston": "^3.19.0",
|
package/src/broken-pipe.ts
CHANGED
|
@@ -9,6 +9,16 @@
|
|
|
9
9
|
import * as fs from "node:fs";
|
|
10
10
|
|
|
11
11
|
const KNOWN_SINK_PEER_CLOSED_CODES = new Set(["EPIPE", "ERR_STREAM_DESTROYED"]);
|
|
12
|
+
/**
|
|
13
|
+
* Errno codes that mean the process's own stdout sink has gone away because
|
|
14
|
+
* the peer (terminal emulator, pager, pipe reader, or pty) was torn down. On
|
|
15
|
+
* macOS a torn-down pty slave produces `EIO`; a closed fd produces `EBADF`;
|
|
16
|
+
* a closed pipe produces `EPIPE`. All three are the same benign condition:
|
|
17
|
+
* the terminal disconnected.
|
|
18
|
+
*
|
|
19
|
+
* Mirrors `CLOSED_STDERR_ERROR_CODES` in `safe-stderr.ts`; keep in sync.
|
|
20
|
+
*/
|
|
21
|
+
const PROCESS_STDOUT_PEER_CLOSED_CODES = new Set(["EIO", "EPIPE", "EBADF"]);
|
|
12
22
|
|
|
13
23
|
type ErrorProperty = "code" | "fd" | "syscall";
|
|
14
24
|
|
|
@@ -70,9 +80,10 @@ export function isBrokenPipeError(error: unknown): boolean {
|
|
|
70
80
|
}
|
|
71
81
|
|
|
72
82
|
/**
|
|
73
|
-
* A classifier for process-level stdout
|
|
74
|
-
* evidence is private to each factory instance, so
|
|
75
|
-
* intercepted `process.stdout.write` can mark an error
|
|
83
|
+
* A classifier for process-level stdout peer-closed errors (`EPIPE`, `EIO`,
|
|
84
|
+
* `EBADF`). Its direct-write evidence is private to each factory instance, so
|
|
85
|
+
* only the owner that intercepted `process.stdout.write` can mark an error
|
|
86
|
+
* for this classifier.
|
|
76
87
|
*/
|
|
77
88
|
export interface ProcessStdoutEpipeClassifier {
|
|
78
89
|
markDirectProcessStdoutWriteError(error: unknown): void;
|
|
@@ -109,7 +120,8 @@ export function createProcessStdoutEpipeClassifier(): ProcessStdoutEpipeClassifi
|
|
|
109
120
|
if (!isObjectLike(error)) return false;
|
|
110
121
|
|
|
111
122
|
const code = readErrorProperty(error, "code");
|
|
112
|
-
if (!code.available || code.value !== "
|
|
123
|
+
if (!code.available || typeof code.value !== "string" || !PROCESS_STDOUT_PEER_CLOSED_CODES.has(code.value))
|
|
124
|
+
return false;
|
|
113
125
|
|
|
114
126
|
if (directProcessStdoutWriteErrors.has(error)) return true;
|
|
115
127
|
|