querysub 0.26.0 → 0.28.0
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/package.json
CHANGED
|
@@ -121,6 +121,8 @@ export function setGitURLMapping(config: {
|
|
|
121
121
|
gitURLRefMappings.set(getSpecKey(config.spec), config.resolvedPath);
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
const loadTimeIndicatorFileName = "loadTimeIndicator-71cd93ba-1667-49ac-9206-b27930bbd983";
|
|
125
|
+
|
|
124
126
|
/** spec => path that we can use with require */
|
|
125
127
|
let moduleResolver = async (spec: FunctionSpec) => {
|
|
126
128
|
let gitURL = spec.gitURL;
|
|
@@ -145,24 +147,26 @@ let moduleResolver = async (spec: FunctionSpec) => {
|
|
|
145
147
|
const lockFolder = getSubFolder("synced_repos_locks");
|
|
146
148
|
let lockPath = lockFolder + sha256(repoPath).slice(0, 16) + ".loadinglock";
|
|
147
149
|
let exists = fs.existsSync(repoPath);
|
|
148
|
-
if (exists) {
|
|
149
|
-
|
|
150
|
-
exists = false;
|
|
151
|
-
}
|
|
150
|
+
if (exists && !fs.existsSync(repoPath + loadTimeIndicatorFileName)) {
|
|
151
|
+
exists = false;
|
|
152
152
|
}
|
|
153
153
|
if (!exists) {
|
|
154
154
|
await getFileLock(lockPath, async () => {
|
|
155
|
-
if (fs.existsSync(repoPath
|
|
156
|
-
|
|
155
|
+
if (fs.existsSync(repoPath + loadTimeIndicatorFileName)) return;
|
|
156
|
+
|
|
157
|
+
// Remove any previous attempt to sync it
|
|
158
|
+
if (fs.existsSync(repoPath)) {
|
|
157
159
|
await fs.promises.rename(repoPath, repoPath + "_" + Date.now());
|
|
158
160
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
161
|
+
// Clone it
|
|
162
|
+
await executeCommand("git", ["clone", gitURL, repoPath]);
|
|
163
|
+
await executeCommand("git", ["reset", "--hard", spec.gitRef], { cwd: repoPath });
|
|
164
|
+
|
|
165
|
+
// Yarn install
|
|
166
|
+
await executeCommand("yarn", ["install"], { cwd: repoPath });
|
|
167
|
+
|
|
168
|
+
// Mark it as loaded. If we don't reach this point we will move the folder and try again next time
|
|
169
|
+
await fs.promises.writeFile(repoPath + loadTimeIndicatorFileName, Date.now() + "");
|
|
166
170
|
});
|
|
167
171
|
}
|
|
168
172
|
|
|
@@ -220,15 +224,6 @@ async function getFileLock(file: string, callback: () => Promise<void>) {
|
|
|
220
224
|
}
|
|
221
225
|
}
|
|
222
226
|
|
|
223
|
-
async function isRepoCloned(path: string): Promise<boolean> {
|
|
224
|
-
try {
|
|
225
|
-
await executeCommand("git", ["-C", path, "rev-parse", "--is-inside-work-tree"]);
|
|
226
|
-
return true;
|
|
227
|
-
} catch {
|
|
228
|
-
return false;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
227
|
export function isDynamicModule(module: NodeJS.Module): boolean {
|
|
233
228
|
return isDynamicModulePath(module.filename);
|
|
234
229
|
}
|
|
@@ -37,6 +37,7 @@ import { getCallResultPath } from "./querysubPrediction";
|
|
|
37
37
|
import { pathValueAuthority2 } from "../0-path-value-core/NodePathAuthorities";
|
|
38
38
|
import { diskLog } from "../diagnostics/logs/diskLogger";
|
|
39
39
|
import { assertIsManagementUser } from "../diagnostics/managementPages";
|
|
40
|
+
import { getBrowserUrlNode } from "../-f-node-discovery/NodeDiscovery";
|
|
40
41
|
setFlag(require, "preact", "allowclient", true);
|
|
41
42
|
|
|
42
43
|
export { Querysub, id };
|
|
@@ -49,7 +50,15 @@ export { Querysub, id };
|
|
|
49
50
|
// very lightweight, hopefully...)
|
|
50
51
|
// - I guess we track our watches, but even that... should be fairly light, and... there
|
|
51
52
|
// is little benefit to sharding that?
|
|
52
|
-
export const querysubNodeId = lazy(() =>
|
|
53
|
+
export const querysubNodeId = lazy(() => {
|
|
54
|
+
if (isNode()) {
|
|
55
|
+
return getControllerNodeId(QuerysubController);
|
|
56
|
+
} else {
|
|
57
|
+
// NOTE: We won't be able to directly connect to some querysub nodes (because they are from other
|
|
58
|
+
// developers), so... just use the browser url.
|
|
59
|
+
return getBrowserUrlNode();
|
|
60
|
+
}
|
|
61
|
+
});
|
|
53
62
|
|
|
54
63
|
setImmediate(() => {
|
|
55
64
|
async function querysubWatchLatest(config: WatchConfig) {
|
|
@@ -19,6 +19,7 @@ import { setFlag } from "socket-function/require/compileFlags";
|
|
|
19
19
|
import cbor from "cbor-x";
|
|
20
20
|
import { FunctionMetadata } from "../3-path-functions/syncSchema";
|
|
21
21
|
import { isNode, nextId, sort } from "socket-function/src/misc";
|
|
22
|
+
import { getBrowserUrlNode } from "../-f-node-discovery/NodeDiscovery";
|
|
22
23
|
setFlag(require, "cbor-x", "allowclient", true);
|
|
23
24
|
const cborEncoder = lazy(() => new cbor.Encoder({ structuredClone: true }));
|
|
24
25
|
|
|
@@ -85,7 +85,7 @@ function logResourcesNow() {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
registerMeasureInfo(() => {
|
|
88
|
-
return formatNumber(getHeapSize())
|
|
88
|
+
return `${formatNumber(getUsedHeapSize())}B+${formatNumber(getBufferUsage())}B/${formatNumber(getHeapSize())}B`;
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
registerPeriodic(logResourcesNow);
|