edfcore 0.4.174 → 0.4.175

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/cli.js CHANGED
@@ -23,6 +23,23 @@ import { isEdfError } from './errors.js';
23
23
  const fs = nodeFsPromises;
24
24
  const proc = nodeProcess.default ??
25
25
  nodeProcess;
26
+ /*
27
+ * A closed pipe is not an error, and Node treats it as one.
28
+ *
29
+ * `edfcore signals big.edf | head -1` closes stdout while the CLI is still writing. The write
30
+ * fails with EPIPE, nothing is listening for `error` on the stream, and Node's default is to
31
+ * rethrow it as an uncaught exception — so a command documented "for grep and awk" answered a
32
+ * perfectly ordinary shell idiom with a kilobyte of stack trace on stderr. `head`, `less`,
33
+ * `grep -m1` and a `jq` that exits early all do this.
34
+ *
35
+ * Swallowed rather than reported: the consumer got what it asked for and stopped listening, which
36
+ * is what it is entitled to do. The remaining writes are dropped by the same handler, since the
37
+ * stream stays broken (fixed in 0.4.175).
38
+ */
39
+ proc.stdout.on('error', (error) => {
40
+ if (error?.code !== 'EPIPE')
41
+ throw error;
42
+ });
26
43
  const io = {
27
44
  readFile: (path) => fs.readFile(path),
28
45
  out: (text) => {
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AAEH,8FAA8F;AAC9F,2FAA2F;AAC3F,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACnD,qDAAqD;AACrD,uFAAuF;AACvF,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAc,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAYzC,MAAM,EAAE,GAAW,cAAmC,CAAC;AACvD,MAAM,IAAI,GACP,WAAoD,CAAC,OAAO;IAC5D,WAAsC,CAA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,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5F,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,OAAO,IAAI,CAAC,CAAC;QAC3C,4FAA4F;QAC5F,0FAA0F;QAC1F,gBAAgB;QAChB,IAAI,CAAC,QAAQ,GAAG,KAAK,YAAY,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;AACH,CAAC;AAED,8FAA8F;AAC9F,+FAA+F;AAC/F,6DAA6D;AAC7D,KAAK,IAAI,EAAE,CAAC"}
@@ -109,5 +109,5 @@ export declare const SIGNAL_FIELD_BLOCK_OFFSETS: {
109
109
  readonly reserved: 224;
110
110
  };
111
111
  /** Published package version. Kept in sync with package.json by a test. */
112
- export declare const VERSION = "0.4.174";
112
+ export declare const VERSION = "0.4.175";
113
113
  //# sourceMappingURL=constants.d.ts.map
package/dist/constants.js CHANGED
@@ -79,5 +79,5 @@ export const SIGNAL_FIELD_BLOCK_OFFSETS = {
79
79
  reserved: 224,
80
80
  };
81
81
  /** Published package version. Kept in sync with package.json by a test. */
82
- export const VERSION = '0.4.174';
82
+ export const VERSION = '0.4.175';
83
83
  //# sourceMappingURL=constants.js.map
package/docs/CHANGELOG.md CHANGED
@@ -6,6 +6,15 @@ alone does not tell you whether you were affected.
6
6
  edfcore is pre-1.0. Patch releases have carried behaviour changes where the old behaviour was a
7
7
  defect; those are called out below.
8
8
 
9
+ ## 0.4.175
10
+
11
+ - **Fixed** the CLI crashing when its output is piped into something that stops reading.
12
+ `edfcore signals big.edf | head -1` closed stdout mid-write; nothing listened for `error` on the
13
+ stream, so Node rethrew EPIPE as an uncaught exception and printed a kilobyte of stack trace to
14
+ stderr. `head`, `less`, `grep -m1` and a `jq` that exits early all do this, and `signals` is
15
+ documented "for grep and awk". A closed pipe is now swallowed: the consumer got what it asked for
16
+ and is entitled to stop listening. Every other stdout error still throws.
17
+
9
18
  ## 0.4.174
10
19
 
11
20
  - **Added** `FormatHeaderOptions.diagnosticsHint`, and turned it off in `edfcore header`. That
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edfcore",
3
- "version": "0.4.174",
3
+ "version": "0.4.175",
4
4
  "description": "Modern, typed, zero-dependency reader for EDF, EDF+, BDF and BDF+ biosignal files. Works in browsers and Node with true random access.",
5
5
  "keywords": [
6
6
  "edf",
package/src/cli.ts CHANGED
@@ -28,7 +28,10 @@ interface NodeFs {
28
28
  interface NodeProcess {
29
29
  readonly argv: readonly string[];
30
30
  exitCode: number | undefined;
31
- readonly stdout: { write(text: string): unknown };
31
+ readonly stdout: {
32
+ write(text: string): unknown;
33
+ on(event: string, listener: (error: { code?: string }) => void): unknown;
34
+ };
32
35
  readonly stderr: { write(text: string): unknown };
33
36
  }
34
37
 
@@ -37,6 +40,23 @@ const proc: NodeProcess =
37
40
  (nodeProcess as unknown as { default?: NodeProcess }).default ??
38
41
  (nodeProcess as unknown as NodeProcess);
39
42
 
43
+ /*
44
+ * A closed pipe is not an error, and Node treats it as one.
45
+ *
46
+ * `edfcore signals big.edf | head -1` closes stdout while the CLI is still writing. The write
47
+ * fails with EPIPE, nothing is listening for `error` on the stream, and Node's default is to
48
+ * rethrow it as an uncaught exception — so a command documented "for grep and awk" answered a
49
+ * perfectly ordinary shell idiom with a kilobyte of stack trace on stderr. `head`, `less`,
50
+ * `grep -m1` and a `jq` that exits early all do this.
51
+ *
52
+ * Swallowed rather than reported: the consumer got what it asked for and stopped listening, which
53
+ * is what it is entitled to do. The remaining writes are dropped by the same handler, since the
54
+ * stream stays broken (fixed in 0.4.175).
55
+ */
56
+ proc.stdout.on('error', (error) => {
57
+ if (error?.code !== 'EPIPE') throw error;
58
+ });
59
+
40
60
  const io: CliIo = {
41
61
  readFile: (path) => fs.readFile(path),
42
62
  out: (text) => {
package/src/constants.ts CHANGED
@@ -93,4 +93,4 @@ export const SIGNAL_FIELD_BLOCK_OFFSETS = {
93
93
  } as const;
94
94
 
95
95
  /** Published package version. Kept in sync with package.json by a test. */
96
- export const VERSION = '0.4.174';
96
+ export const VERSION = '0.4.175';