@ladybugdb/core-linux-x64 0.21.0-dev.20260924 → 0.21.0-dev.20260927
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/connection.js +24 -6
- package/lbugjs.node +0 -0
- package/package.json +1 -1
package/connection.js
CHANGED
|
@@ -41,18 +41,23 @@ class Connection {
|
|
|
41
41
|
if (this._isClosed) {
|
|
42
42
|
throw new Error("Connection is closed.");
|
|
43
43
|
}
|
|
44
|
-
if (
|
|
45
|
-
|
|
44
|
+
if (this._isInitialized) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!this._initPromise) {
|
|
48
|
+
// Cache the promise synchronously (no await before assignment) so
|
|
49
|
+
// concurrent init() calls share a single initialization instead of
|
|
50
|
+
// each starting their own (which crashed the process, see #24).
|
|
51
|
+
this._initPromise = (async () => {
|
|
52
|
+
const database = await this._database._getDatabase();
|
|
46
53
|
if (!this._connection) {
|
|
47
|
-
const database = await this._database._getDatabase();
|
|
48
54
|
this._connection = new LbugNative.NodeConnection(database);
|
|
49
55
|
}
|
|
50
|
-
|
|
56
|
+
await new Promise((resolve, reject) => {
|
|
51
57
|
this._connection.initAsync((err) => {
|
|
52
58
|
if (err) {
|
|
53
59
|
reject(err);
|
|
54
60
|
} else {
|
|
55
|
-
this._isInitialized = true;
|
|
56
61
|
if (this._numThreads) {
|
|
57
62
|
this._connection.setMaxNumThreadForExec(this._numThreads);
|
|
58
63
|
}
|
|
@@ -63,8 +68,21 @@ class Connection {
|
|
|
63
68
|
}
|
|
64
69
|
});
|
|
65
70
|
});
|
|
71
|
+
this._isInitialized = true;
|
|
72
|
+
})();
|
|
73
|
+
}
|
|
74
|
+
const initPromise = this._initPromise;
|
|
75
|
+
try {
|
|
76
|
+
await initPromise;
|
|
77
|
+
} catch (err) {
|
|
78
|
+
// Allow retry after a failed initialization (clear only if no
|
|
79
|
+
// newer init has started in the meantime).
|
|
80
|
+
if (this._initPromise === initPromise) {
|
|
81
|
+
this._initPromise = null;
|
|
66
82
|
}
|
|
67
|
-
|
|
83
|
+
throw err;
|
|
84
|
+
}
|
|
85
|
+
if (this._initPromise === initPromise) {
|
|
68
86
|
this._initPromise = null;
|
|
69
87
|
}
|
|
70
88
|
}
|
package/lbugjs.node
CHANGED
|
Binary file
|
package/package.json
CHANGED