edfcore 0.3.42 → 0.3.43

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/CHANGELOG.md CHANGED
@@ -6,6 +6,26 @@ 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.3.43
10
+
11
+ - **Fixed** `cachedSource` letting one reader's abort cancel unrelated concurrent readers. A block
12
+ read serves every reader of that block — the dedup is the point — but it carried the FIRST
13
+ caller's options, `signal` included. Aborting one reader rejected the others, **including a
14
+ reader that passed no signal at all**, with `AbortError: The read was aborted through
15
+ options.signal` describing something that never happened to it.
16
+ - That is the ordinary stale-request pattern in a viewer: the user scrolls, the app aborts the
17
+ window they left and issues the new one. Both land in the same 1 MiB block, and the **fresh**
18
+ window is the one that dies. Because the message reads as self-cancellation, the app's own
19
+ `catch` swallows it — a blank panel and no error anywhere. Which reader died depended on which
20
+ touched the block first.
21
+ - The shared read no longer carries a signal. `read` already polls each caller's own signal before
22
+ and after the block joins, so an aborting caller still rejects promptly; it simply no longer
23
+ decides for anyone else. The cost is that an abort does not tear down the underlying request,
24
+ which is the right trade for a read other readers are waiting on — the bytes are valid and
25
+ already paid for, so they are admitted to the cache and a later read is served from it.
26
+ - One underlying read per block, exactly as before. `maxMaterializeBytes` still travels with the
27
+ shared read, because that one genuinely is a property of the fetch rather than of a caller.
28
+
9
29
  ## 0.3.42
10
30
 
11
31
  - **Fixed** `toPhysical` and `clampToDigitalRange` reporting a *"NaN-byte maxMaterializeBytes
@@ -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.3.42";
112
+ export declare const VERSION = "0.3.43";
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.3.42';
82
+ export const VERSION = '0.3.43';
83
83
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cached.d.ts","sourceRoot":"","sources":["../../src/io/cached.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAe,MAAM,aAAa,CAAC;AAmBzE,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,UAAU,CAsHnF"}
1
+ {"version":3,"file":"cached.d.ts","sourceRoot":"","sources":["../../src/io/cached.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAe,MAAM,aAAa,CAAC;AAmBzE,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,UAAU,CA4InF"}
package/dist/io/cached.js CHANGED
@@ -65,10 +65,31 @@ export function cachedSource(source, options) {
65
65
  cachedBytes += block.byteLength;
66
66
  evict();
67
67
  }
68
+ /**
69
+ * The shared block read, deliberately WITHOUT the caller's signal.
70
+ *
71
+ * One block read serves every concurrent reader of that block, so letting one of them cancel it
72
+ * cancels the others. A viewer using the ordinary stale-request pattern — abort the controller
73
+ * for the window the user scrolled away from — killed the FRESH window whenever both landed in
74
+ * the same block, with `AbortError: The read was aborted through options.signal` describing
75
+ * something that never happened to it. A reader that passed no signal at all was rejected the
76
+ * same way, and because the message reads as self-cancellation the app's own `catch` swallows
77
+ * it: a blank panel and no error anywhere. Which reader died depended on which touched the
78
+ * block first (fixed in 0.3.43).
79
+ *
80
+ * `read` already polls each caller's own signal before and after `Promise.all`, so an aborting
81
+ * caller still rejects promptly — it simply no longer decides for anyone else. The cost is that
82
+ * an abort does not tear down the underlying request, which is the right trade for a read whose
83
+ * result other readers are waiting on: the bytes are valid and already paid for, so they are
84
+ * admitted to the cache.
85
+ */
68
86
  async function fetchBlock(index, options) {
69
87
  const start = index * blockBytes;
70
88
  const length = Math.min(blockBytes, byteLength - start);
71
- return assertExactRead(await source.read(start, length, options), start, length);
89
+ const shared = options?.maxMaterializeBytes === undefined
90
+ ? undefined
91
+ : { maxMaterializeBytes: options.maxMaterializeBytes };
92
+ return assertExactRead(await source.read(start, length, shared), start, length);
72
93
  }
73
94
  function blockFor(index, options) {
74
95
  const cached = blocks.get(index);
@@ -78,8 +99,8 @@ export function cachedSource(source, options) {
78
99
  return Promise.resolve(cached);
79
100
  }
80
101
  const pending = inflight.get(index);
81
- // Deduped readers share the first caller's options, which is inherent to issuing one read
82
- // for all of them.
102
+ // Deduped readers share one underlying read, which is the whole point. They no longer share a
103
+ // signal see `fetchBlock`.
83
104
  if (pending !== undefined)
84
105
  return pending;
85
106
  const started = fetchBlock(index, options)
@@ -1 +1 @@
1
- {"version":3,"file":"cached.js","sourceRoot":"","sources":["../../src/io/cached.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE/E,MAAM,mBAAmB,GAAG,IAAI,GAAG,IAAI,CAAC;AACxC,MAAM,iBAAiB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAE3C,yFAAyF;AACzF,SAAS,WAAW,CAAC,MAAkB;IACrC,OAAO;QACL,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,KAAK,CAAC,IAAI,CAAC,MAAc,EAAE,MAAc,EAAE,OAAqB;YAC9D,OAAO,eAAe,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OA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CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,GAAG,UAAU,EAAE,EAAE,GAAG,UAAU,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,CAAC;YAC7E,CAAC;YACD,OAAO,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAC9C,CAAC;QACD,KAAK,CAAC,KAAK;YACT,4FAA4F;YAC5F,8EAA8E;YAC9E,MAAM,GAAG,IAAI,CAAC;YACd,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,QAAQ,CAAC,KAAK,EAAE,CAAC;YACjB,WAAW,GAAG,CAAC,CAAC;YAChB,MAAM,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;QACzB,CAAC;KACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edfcore",
3
- "version": "0.3.42",
3
+ "version": "0.3.43",
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/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.3.42';
96
+ export const VERSION = '0.3.43';
package/src/io/cached.ts CHANGED
@@ -78,10 +78,32 @@ export function cachedSource(source: ByteSource, options?: CacheOptions): ByteSo
78
78
  evict();
79
79
  }
80
80
 
81
+ /**
82
+ * The shared block read, deliberately WITHOUT the caller's signal.
83
+ *
84
+ * One block read serves every concurrent reader of that block, so letting one of them cancel it
85
+ * cancels the others. A viewer using the ordinary stale-request pattern — abort the controller
86
+ * for the window the user scrolled away from — killed the FRESH window whenever both landed in
87
+ * the same block, with `AbortError: The read was aborted through options.signal` describing
88
+ * something that never happened to it. A reader that passed no signal at all was rejected the
89
+ * same way, and because the message reads as self-cancellation the app's own `catch` swallows
90
+ * it: a blank panel and no error anywhere. Which reader died depended on which touched the
91
+ * block first (fixed in 0.3.43).
92
+ *
93
+ * `read` already polls each caller's own signal before and after `Promise.all`, so an aborting
94
+ * caller still rejects promptly — it simply no longer decides for anyone else. The cost is that
95
+ * an abort does not tear down the underlying request, which is the right trade for a read whose
96
+ * result other readers are waiting on: the bytes are valid and already paid for, so they are
97
+ * admitted to the cache.
98
+ */
81
99
  async function fetchBlock(index: number, options?: ReadOptions): Promise<Uint8Array> {
82
100
  const start = index * blockBytes;
83
101
  const length = Math.min(blockBytes, byteLength - start);
84
- return assertExactRead(await source.read(start, length, options), start, length);
102
+ const shared: ReadOptions | undefined =
103
+ options?.maxMaterializeBytes === undefined
104
+ ? undefined
105
+ : { maxMaterializeBytes: options.maxMaterializeBytes };
106
+ return assertExactRead(await source.read(start, length, shared), start, length);
85
107
  }
86
108
 
87
109
  function blockFor(index: number, options?: ReadOptions): Promise<Uint8Array> {
@@ -92,8 +114,8 @@ export function cachedSource(source: ByteSource, options?: CacheOptions): ByteSo
92
114
  return Promise.resolve(cached);
93
115
  }
94
116
  const pending = inflight.get(index);
95
- // Deduped readers share the first caller's options, which is inherent to issuing one read
96
- // for all of them.
117
+ // Deduped readers share one underlying read, which is the whole point. They no longer share a
118
+ // signal see `fetchBlock`.
97
119
  if (pending !== undefined) return pending;
98
120
 
99
121
  const started = fetchBlock(index, options)