sqlite-executor 4.0.10 → 4.0.11
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/cjs/index.cjs
CHANGED
|
@@ -56,7 +56,30 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
var DEFAULT_STATEMENT_TIMEOUT = 30000;
|
|
59
|
-
function
|
|
59
|
+
function formatDateTime(date) {
|
|
60
|
+
var y = date.getFullYear();
|
|
61
|
+
var M = String(date.getMonth() + 1).padStart(2, "0");
|
|
62
|
+
var d = String(date.getDate()).padStart(2, "0");
|
|
63
|
+
var h = String(date.getHours()).padStart(2, "0");
|
|
64
|
+
var m = String(date.getMinutes()).padStart(2, "0");
|
|
65
|
+
var s = String(date.getSeconds()).padStart(2, "0");
|
|
66
|
+
var ms = String(date.getMilliseconds()).padStart(3, "0");
|
|
67
|
+
return "".concat(y, "-").concat(M, "-").concat(d, " ").concat(h, ":").concat(m, ":").concat(s, ".").concat(ms);
|
|
68
|
+
}
|
|
69
|
+
function formatDuration(ms) {
|
|
70
|
+
if (ms < 1000) return "".concat(ms, "ms");
|
|
71
|
+
if (ms < 60000) return "".concat((ms / 1000).toFixed(1), "s");
|
|
72
|
+
var mins = Math.floor(ms / 60000);
|
|
73
|
+
var secs = (ms % 60000 / 1000).toFixed(1);
|
|
74
|
+
return "".concat(mins, "m ").concat(secs, "s");
|
|
75
|
+
}
|
|
76
|
+
function createTimeoutError(timeout, sql, startTime) {
|
|
77
|
+
if (void 0 !== startTime) {
|
|
78
|
+
var elapsed = Math.max(0, performance.now() - startTime);
|
|
79
|
+
var startDate = new Date(Date.now() - elapsed);
|
|
80
|
+
var deadlineDate = new Date(startDate.getTime() + timeout);
|
|
81
|
+
return new Error("SQLite statement timed out after ".concat(formatDuration(timeout), " ") + "(start: ".concat(formatDateTime(startDate), ", ") + "deadline: ".concat(formatDateTime(deadlineDate), "): ").concat(sql));
|
|
82
|
+
}
|
|
60
83
|
return new Error("SQLite statement timed out after ".concat(timeout, "ms: ").concat(sql));
|
|
61
84
|
}
|
|
62
85
|
function toError(value) {
|
|
@@ -2270,7 +2293,7 @@ function prepareTaskTimeout(task, metrics) {
|
|
|
2270
2293
|
if (task.settled) return null;
|
|
2271
2294
|
task.timedout = true;
|
|
2272
2295
|
null == metrics || metrics.incrementTasksTimeout();
|
|
2273
|
-
return createTimeoutError(task.timeout, task.sql);
|
|
2296
|
+
return createTimeoutError(task.timeout, task.sql, task.startTime);
|
|
2274
2297
|
}
|
|
2275
2298
|
function createSweeper(param) {
|
|
2276
2299
|
var inflight = param.inflight, sweepIntervalMs = param.sweepIntervalMs, handleTaskTimeout = param.handleTaskTimeout;
|