@goodandready/dsh-cron 0.2.43 → 0.2.44

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/lib/client.js CHANGED
@@ -1507,10 +1507,18 @@ window.__ModuleLoader__.load({
1507
1507
  ...options,
1508
1508
  signal: controller ? controller.signal : options.signal,
1509
1509
  });
1510
- const data = await res.json().catch(() => ({}));
1510
+ let data = {};
1511
+ try {
1512
+ data = await res.json();
1513
+ } catch (jsonErr) {
1514
+ // Re-throw if body reading aborted/timed out (#242)
1515
+ if (jsonErr && (jsonErr.name === 'AbortError' || controller?.signal.aborted)) {
1516
+ throw jsonErr;
1517
+ }
1518
+ }
1511
1519
  return { res, data };
1512
1520
  } catch (err) {
1513
- if (err && err.name === 'AbortError') {
1521
+ if (err && (err.name === 'AbortError' || controller?.signal.aborted)) {
1514
1522
  const timeoutErr = new Error(`Request timed out after ${Math.round(timeoutMs / 1000)}s`);
1515
1523
  timeoutErr.isTimeout = true;
1516
1524
  throw timeoutErr;
package/lib/index.js CHANGED
@@ -80,6 +80,7 @@ import {
80
80
  sanitizeSettingsPayload,
81
81
  unwrapConfig,
82
82
  unwrapConfigValue,
83
+ plainConfig,
83
84
  } from './settings.js';
84
85
  import { registerRoutes } from './routes.js';
85
86
 
@@ -90,6 +91,7 @@ export {
90
91
  sanitizeSettingsPayload,
91
92
  unwrapConfig,
92
93
  unwrapConfigValue,
94
+ plainConfig,
93
95
  };
94
96
 
95
97
  export const name = '@goodandready/dsh-cron';
@@ -119,7 +121,7 @@ const pkgVersion = JSON.parse(fs.readFileSync(pkgUrl, 'utf8')).version || '0.2.2
119
121
 
120
122
  export function apply(ctx, rawConfig) {
121
123
  if (ctx && ctx.logger) setLogger(ctx.logger);
122
- const config = unwrapConfig(rawConfig);
124
+ const config = plainConfig(rawConfig);
123
125
  const storePath = (config && (config.cronDir || config.storePath)) ? (config.storePath || path.join(config.cronDir, 'tasks.json')) : undefined;
124
126
  const store = new TaskStore(storePath);
125
127
 
package/lib/settings.js CHANGED
@@ -53,28 +53,21 @@ export const Config = z.object({
53
53
 
54
54
 
55
55
  /**
56
- * Unwrap a volatile config reference or wrap a config object in a transparent Proxy.
56
+ * Deeply unwrap Cosmokit/Schemastery Volatile boxes into plain primitives/objects/arrays (#282).
57
57
  */
58
- export function unwrapConfigValue(val) {
59
- if (val && typeof val === 'object' && typeof val.get === 'function') {
60
- return val.get();
58
+ export function plainConfig(value) {
59
+ if (value === null || value === undefined) return value;
60
+ if (typeof value === 'function') return plainConfig(value());
61
+ if (typeof value.get === 'function') return plainConfig(value.get());
62
+ if (Array.isArray(value)) return value.map(plainConfig);
63
+ if (typeof value === 'object') {
64
+ return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, plainConfig(v)]));
61
65
  }
62
- return val;
66
+ return value;
63
67
  }
64
68
 
65
- export function unwrapConfig(cfg) {
66
- if (!cfg || typeof cfg !== 'object') return cfg;
67
- if (typeof cfg.get === 'function') return unwrapConfig(cfg.get());
68
- return new Proxy(cfg, {
69
- get(target, prop, receiver) {
70
- const val = Reflect.get(target, prop, receiver);
71
- if (val && typeof val === 'object' && typeof val.get === 'function') {
72
- return val.get();
73
- }
74
- return val;
75
- }
76
- });
77
- }
69
+ export const unwrapConfigValue = plainConfig;
70
+ export const unwrapConfig = plainConfig;
78
71
 
79
72
  export const SETTINGS_SYNC_KEYS = [
80
73
  'botToken', 'botTokenRef', 'telegramWebhookSecret', 'chatId', 'notifyTelegram', 'onlyOnFailure', 'kanbanBaseUrl',
package/lib/store.js CHANGED
@@ -209,8 +209,11 @@ export class TaskStore {
209
209
  this._lastWrittenVersion = version;
210
210
  } catch (err) {
211
211
  this._currentAsyncTmp = null;
212
- // If tmp was unlinked by newer sync save, rename will fail with ENOENT - safely ignore
213
- if (err.code !== 'ENOENT') throw err;
212
+ // If tmp was unlinked by newer sync save, rename will fail with ENOENT - safely ignore only in that case (#244)
213
+ if (err.code === 'ENOENT' && (this._lastSyncVersion || 0) >= version) {
214
+ return;
215
+ }
216
+ throw err;
214
217
  }
215
218
 
216
219
  const now = Date.now();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-cron",
3
- "version": "0.2.43",
3
+ "version": "0.2.44",
4
4
  "description": "Background automation runner for DSH: isolated agent runs, script/HTTP/SSH/Docker runtimes, cost guard, notifications, heartbeats.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",