@stonyx/logs 1.0.1-alpha.22 → 1.0.1-alpha.23
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/index.js +12 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20,10 +20,18 @@ const defaultOptions = {
|
|
|
20
20
|
// used to sanitize defineType() options input
|
|
21
21
|
const optionKeys = Object.keys(defaultOptions);
|
|
22
22
|
/*
|
|
23
|
-
* Write failures
|
|
24
|
-
*
|
|
23
|
+
* Write failures that a recursive mkdir of the log directory can actually repair:
|
|
24
|
+
* ENOENT (the cached directory was removed at runtime) and ENOTDIR (a path component
|
|
25
|
+
* was replaced by a non-directory). These invalidate the directory cache and are
|
|
26
|
+
* retried once.
|
|
27
|
+
*
|
|
28
|
+
* Permission and mount faults (EACCES, EPERM, EROFS) are deliberately excluded: the
|
|
29
|
+
* retry's only remediation is mkdir(recursive), which is a successful no-op on an
|
|
30
|
+
* existing directory and can change neither a mode nor a mount flag. Retrying them
|
|
31
|
+
* doubled the syscalls on a permanently failing write and defeated the
|
|
32
|
+
* one-mkdir-per-directory invariant this cache exists to establish.
|
|
25
33
|
*/
|
|
26
|
-
const recoverableWriteCodes = new Set(['ENOENT', '
|
|
34
|
+
const recoverableWriteCodes = new Set(['ENOENT', 'ENOTDIR']);
|
|
27
35
|
export default class Log {
|
|
28
36
|
options;
|
|
29
37
|
color;
|
|
@@ -138,7 +146,7 @@ export default class Log {
|
|
|
138
146
|
}
|
|
139
147
|
catch (error) {
|
|
140
148
|
const { code } = error;
|
|
141
|
-
if (!
|
|
149
|
+
if (!recoverableWriteCodes.has(code))
|
|
142
150
|
throw error;
|
|
143
151
|
/*
|
|
144
152
|
* The cached directory may have been removed underneath a warm cache. Invalidate
|