jexidb 2.2.3 → 2.2.6
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/README.md +50 -0
- package/dist/Database.cjs +745 -157
- package/package.json +1 -1
- package/src/Database.mjs +274 -28
- package/src/FileHandler.mjs +88 -1
- package/src/managers/IndexManager.mjs +55 -6
- package/src/managers/QueryManager.mjs +320 -132
- package/src/utils/ioTimeout.mjs +36 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers to normalize and detect I/O timeout / abort errors.
|
|
3
|
+
*
|
|
4
|
+
* Node surfaces read timeouts in several inconsistent shapes depending on the
|
|
5
|
+
* path used (`error.name`, `error.code` or `error.message`). These helpers
|
|
6
|
+
* centralize creation and detection so every retry branch across Database.mjs
|
|
7
|
+
* and FileHandler.mjs agrees, and timeouts are always delivered as normal
|
|
8
|
+
* promise rejections - never as an `uncaughtException`.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Create a normalized I/O timeout error that every retry branch recognizes.
|
|
13
|
+
* @param {number} timeoutMs - Timeout that elapsed, in milliseconds.
|
|
14
|
+
* @returns {Error}
|
|
15
|
+
*/
|
|
16
|
+
export function createIoTimeoutError(timeoutMs) {
|
|
17
|
+
const err = new Error(`I/O timeout after ${timeoutMs}ms`)
|
|
18
|
+
err.name = 'AbortError'
|
|
19
|
+
err.code = 'ETIMEDOUT'
|
|
20
|
+
return err
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Detect whether an error represents an I/O timeout or abort, regardless of the
|
|
25
|
+
* shape it was produced in.
|
|
26
|
+
* @param {*} error - Error to inspect (may be null/undefined).
|
|
27
|
+
* @returns {boolean}
|
|
28
|
+
*/
|
|
29
|
+
export function isIoTimeoutError(error) {
|
|
30
|
+
if (!error) return false
|
|
31
|
+
return (
|
|
32
|
+
error.name === 'AbortError' ||
|
|
33
|
+
error.code === 'ETIMEDOUT' ||
|
|
34
|
+
error.message === 'AbortError'
|
|
35
|
+
)
|
|
36
|
+
}
|