querysub 0.374.0 → 0.376.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.
Files changed (38) hide show
  1. package/package.json +2 -4
  2. package/src/deployManager/components/MachineDetailPage.tsx +2 -5
  3. package/src/deployManager/components/ServiceDetailPage.tsx +2 -5
  4. package/src/deployManager/machineApplyMainCode.ts +7 -0
  5. package/src/diagnostics/NodeViewer.tsx +4 -5
  6. package/src/diagnostics/logs/IndexedLogs/BufferIndex.ts +10 -5
  7. package/src/diagnostics/logs/IndexedLogs/BufferIndexCPP.cpp +20 -0
  8. package/src/diagnostics/logs/IndexedLogs/BufferIndexHelpers.ts +29 -2
  9. package/src/diagnostics/logs/IndexedLogs/BufferUnitIndex.ts +61 -20
  10. package/src/diagnostics/logs/IndexedLogs/BufferUnitSet.ts +2 -2
  11. package/src/diagnostics/logs/IndexedLogs/IndexedLogs.ts +7 -7
  12. package/src/diagnostics/logs/IndexedLogs/LogViewer3.tsx +250 -243
  13. package/src/diagnostics/logs/IndexedLogs/LogViewerParams.ts +21 -0
  14. package/src/diagnostics/logs/IndexedLogs/{bufferMatcher.ts → bufferSearchFindMatcher.ts} +9 -4
  15. package/src/diagnostics/logs/IndexedLogs/moveIndexLogsToPublic.ts +3 -3
  16. package/src/diagnostics/logs/diskLogger.ts +0 -38
  17. package/src/diagnostics/logs/errorNotifications2/errorNotifications2.ts +9 -0
  18. package/src/diagnostics/logs/injectFileLocationToConsole.ts +3 -0
  19. package/src/diagnostics/logs/lifeCycleAnalysis/lifeCycles.tsx +24 -22
  20. package/src/diagnostics/managementPages.tsx +0 -18
  21. package/test.ts +0 -5
  22. package/bin/error-email.js +0 -8
  23. package/bin/error-im.js +0 -8
  24. package/src/diagnostics/logs/FastArchiveAppendable.ts +0 -843
  25. package/src/diagnostics/logs/FastArchiveController.ts +0 -573
  26. package/src/diagnostics/logs/FastArchiveViewer.tsx +0 -1090
  27. package/src/diagnostics/logs/LogViewer2.tsx +0 -552
  28. package/src/diagnostics/logs/errorNotifications/ErrorDigestPage.tsx +0 -409
  29. package/src/diagnostics/logs/errorNotifications/ErrorNotificationController.ts +0 -756
  30. package/src/diagnostics/logs/errorNotifications/ErrorSuppressionUI.tsx +0 -280
  31. package/src/diagnostics/logs/errorNotifications/ErrorWarning.tsx +0 -254
  32. package/src/diagnostics/logs/errorNotifications/errorDigestEmail.tsx +0 -233
  33. package/src/diagnostics/logs/errorNotifications/errorDigestEntry.tsx +0 -14
  34. package/src/diagnostics/logs/errorNotifications/errorDigests.tsx +0 -292
  35. package/src/diagnostics/logs/errorNotifications/errorWatchEntry.tsx +0 -209
  36. package/src/diagnostics/logs/importLogsEntry.ts +0 -38
  37. package/src/diagnostics/logs/lifeCycleAnalysis/LifeCyclePages.tsx +0 -150
  38. package/src/diagnostics/logs/logViewerExtractField.ts +0 -36
@@ -147,7 +147,7 @@ export async function moveLogsToPublic(config: {
147
147
  }));
148
148
  if (buffers.length === 0) continue;
149
149
 
150
- console.log(magenta(`Merging and moving ${group.length} log files backblaze`));
150
+ console.log(magenta(`Merging and moving ${group.length} log files backblaze (${blue(config.loggerName)})`));
151
151
 
152
152
  let allBuffers: Buffer[][] = [];
153
153
 
@@ -188,7 +188,7 @@ export async function moveLogsToPublic(config: {
188
188
  for (let buffer of group) {
189
189
  uncompressedSize += buffer.length;
190
190
  }
191
- let obj = BufferIndex.encodeAll({
191
+ let obj = await BufferIndex.encodeAll({
192
192
  data: group,
193
193
  });
194
194
  encoded.push({
@@ -221,7 +221,7 @@ export async function moveLogsToPublic(config: {
221
221
  await localLogs.del(path.fullPath + indexExtension);
222
222
  }));
223
223
 
224
- console.log(green(`(${i + 1}/${groups.length}) Wrote ${encoded.length} log files to public (${formatNumber(encoded.reduce((acc, x) => acc + x.uncompressedSize, 0))}B compressed to ${formatNumber(encoded.reduce((acc, x) => acc + x.compressedSize, 0))}B + ${formatNumber(encoded.reduce((acc, x) => acc + x.index.length, 0))}B index) in ${formatTime(Date.now() - time)}`));
224
+ console.log(green(`(${i + 1}/${groups.length}) Wrote ${encoded.length} log files to public (${formatNumber(encoded.reduce((acc, x) => acc + x.uncompressedSize, 0))}B compressed to ${formatNumber(encoded.reduce((acc, x) => acc + x.compressedSize, 0))}B + ${formatNumber(encoded.reduce((acc, x) => acc + x.index.length, 0))}B index) in ${formatTime(Date.now() - time)}`) + ` (${blue(config.loggerName)})`);
225
225
  }
226
226
 
227
227
  // Clean up orphaned index files (index files without corresponding data files)
@@ -5,7 +5,6 @@ import { lazy } from "socket-function/src/caching";
5
5
  import { timeInMinute } from "socket-function/src/misc";
6
6
  import { formatTime } from "socket-function/src/formatting/format";
7
7
  import { addEpsilons } from "../../bits";
8
- import { FileMetadata } from "./FastArchiveController";
9
8
  import { getPathStr2 } from "../../path";
10
9
  import { isPublic } from "../../config";
11
10
  // IMPORTANT! We can't have any real imports here, because we are depended on so early in startup!
@@ -32,8 +31,6 @@ export type LogDatum = Record<string, unknown> & {
32
31
  __DIR__?: string;
33
32
  __NAME__?: string;
34
33
  __LINE__?: string;
35
- /** Dynamically set at runtime in the frontend. */
36
- __metadata?: FileMetadata;
37
34
  /** Dynamically set when matching recent errors only. */
38
35
  __matchedOutdatedSuppressionKey?: string;
39
36
  };
@@ -68,36 +65,6 @@ export const LOG_LINE_LIMIT_FLAG = String.fromCharCode(44534) + "LOGS_LINE_LIMIT
68
65
  /** If this key exists in the logged object, as in a key in one of the objects logged, then we will use the value of it as the limit ID. This is useful as it allows us to either override a limit or limit something independently from other logs in the file. */
69
66
  export const LOG_LINE_LIMIT_ID = "LIMIT_LINE_ID";
70
67
 
71
- export const getLoggers = lazy(function () {
72
- const { FastArchiveAppendable } = require("./FastArchiveAppendable") as typeof import("./FastArchiveAppendable");
73
- if (!FastArchiveAppendable) {
74
- setImmediate(() => {
75
- getLoggers.reset();
76
- });
77
- return undefined;
78
- }
79
- return {
80
- logLogs: new FastArchiveAppendable<LogDatum>("logs-log/"),
81
- warnLogs: new FastArchiveAppendable<LogDatum>("logs-warn/"),
82
- infoLogs: new FastArchiveAppendable<LogDatum>("logs-info/"),
83
- errorLogs: new FastArchiveAppendable<LogDatum>("logs-error/"),
84
- };
85
- });
86
- setImmediate(() => {
87
- // If we don't import it at all, then it doesn't work client-side.
88
- require("./FastArchiveAppendable") as typeof import("./FastArchiveAppendable");
89
- });
90
- const getNotifyErrors = lazy(function () {
91
- const { notifyWatchersOfError: notifyErrors } = require("./errorNotifications/ErrorNotificationController") as typeof import("./errorNotifications/ErrorNotificationController");
92
- if (typeof notifyErrors !== "function") {
93
- setImmediate(() => {
94
- getNotifyErrors.reset();
95
- });
96
- return undefined;
97
- }
98
- return notifyErrors;
99
- });
100
-
101
68
  export const getLoggers2 = lazy(function () {
102
69
  const { IndexedLogs } = require("./IndexedLogs/IndexedLogs") as typeof import("./IndexedLogs/IndexedLogs");
103
70
 
@@ -189,11 +156,6 @@ export function logDisk(type: "log" | "warn" | "info" | "error", ...args: unknow
189
156
  }
190
157
  }
191
158
 
192
- if (type === "warn" || type === "error") {
193
- // Dropping notifies is fine, as long as they get added to the logs, we'll see them eventually...
194
- void getNotifyErrors()?.(logObj);
195
- }
196
-
197
159
  } catch (e: any) {
198
160
  process.stdout.write(`Error writing to disk logs: ${e.stack || e}\n\t${String(args[0])}\n`);
199
161
  }
@@ -0,0 +1,9 @@
1
+
2
+ //todonext
3
+
4
+ // single service, no history search, discord messaging, suppression and suppression page
5
+ // - Storing suppression history just in memory? (although suppression values, obviously, on disk)
6
+ // - receive all errors, and service will do suppression
7
+
8
+ // Start with page itself showing errors and suppressing them, for debugging/testing
9
+ // - Ai to automatically create suppression searches, and combine existing ones, etc
@@ -41,4 +41,7 @@ if (isNode()) {
41
41
 
42
42
  let diskShimConsoleLogs = require("./diskShimConsoleLogs") as typeof import("./diskShimConsoleLogs");
43
43
  diskShimConsoleLogs.shimConsoleLogs();
44
+ } else {
45
+ // NOTE: Disable console.info, as serverside we use it for disk only logs
46
+ console.info = () => { };
44
47
  }
@@ -20,12 +20,6 @@ IMPORTANT! Now I am properly calling shutdown, so none of the streamed logs shou
20
20
 
21
21
 
22
22
 
23
- 3) Ensure our moveloops are working correctly, on both dev and public
24
-
25
-
26
- 1) Fix missing __NAME__
27
- "Received PathValue for path" misses name?
28
- - Maybe the missing name only happens when we rate limit?
29
23
 
30
24
  2) Create lot of remote server logs
31
25
  - Via our refresh loop
@@ -39,23 +33,18 @@ IMPORTANT! Now I am properly calling shutdown, so none of the streamed logs shou
39
33
 
40
34
 
41
35
  Rewrite error notification code
42
- THINK about how to do a somewhat generic logs => derived thing, as... we will need the exact same thing for life cycles!
43
- - Maybe make it generic immediately? Having it abstracted it kind of nice for development anyways...
44
- - New service that manages it, instead of doing it on demand
45
- - It asks everyone to send it error logs
46
- - Stores cached error logs => { unsuppressed logs, suppressionSummary }
47
- - Unsuppressed logs only for suppression which is old enough.
48
- - Only when logs are old enough.
49
- - Stores in memory with all suppressionSummaries
50
- AND, the only watcher will be the watcher service. You can't get recent errors, or any errors, without going through one of those
51
- NO dev errors. They are usually red-herrings anyways... and we should just be using public servers for regular usage
52
- - And we still have dev logs we can check if to see if an error happened locally
53
- ALSO owns the discord messaging code
54
-
36
+ - Single service, which talks to all machines
37
+ - We'll have a dev mode, mostly for testing, although we won't usually run it.
38
+ - BROADCASTS messages to all http servers so they show them
39
+ - Broadcast messages only has one type now "error notification", but add TODO for more types, which may display in different ways (via toast, etc)
40
+ - Maybe only streaming? We'll miss some, but... not that much...
41
+ - ALSO owns the discord messaging code
42
+ - Suppression... will work in the service itself. Because there shouldn't be THAT many errors happening!
43
+ - Suppression will use AI to group?
44
+ - BUT, we will still have page that shows suppression list, with counts and times
45
+ - Page links to search, which tries to find those errors (we should use the same format for suppression as search, so it should be fairly easy to do that)
55
46
 
56
47
 
57
- Remove all old LogViewer/FastArchiveAppendable code
58
- - Make sure to find all links and update them as well
59
48
 
60
49
 
61
50
  0) Add LZ4 compression to socket-function by default
@@ -63,12 +52,25 @@ Remove all old LogViewer/FastArchiveAppendable code
63
52
  - default is "lz4"
64
53
  - REQUIRES feature checking the remote, to make sure it is new enough to accept this.
65
54
  - A generic thing which gets the version is probably fine.
55
+ - When decoding, I think we should just check the first byte. It should be a magic number which tells us which compression it's using.
66
56
  - LZ4 compression is fast enough that this should cause basically no overhead, and in many cases greatly reduce the bandwidth (which will increase the speed).
67
57
  - We're gonna have to investigate how we're sending buffers anyway. I think this should be easy, but we
68
- 0.1) Verify the size distance with some local testing
58
+ 0.1) Verify the size difference with some local testing
69
59
  - ALSO, verify the processing overhead is acceptable.
70
60
  1) Deploy, which SHOULD be backwards compatible with everything?
71
61
 
62
+
63
+ -1) Change PathValueSerialize to use LZ4
64
+ - I think we already have a compression flag here, so it should be easy enough to just support it to change it to support LZ4.
65
+ - I think we want to disable the server, and then when we launch the server locally, it should have to read from disk.
66
+ -2) It would probably be valuable to test the synchronization speed between two different servers. It seems like when the remote is running and we start a local server, it really takes a long time for it to get ready. As in minutes.
67
+ - This might have already been fixed by us improving the compression speed to not use gzip, maybe, but we should test it again, and if not, we should see what's slow
68
+ - We might need to jump into the server and look at its profiles there by forcing them to omit, which isn't too hard, but it is kind of annoying.
69
+
70
+ -3) During server startup (when there is a remote server), we spend a lot of time in identityHook.
71
+ - BUT... Our check to see if the async call that we're doing underneath is taking more than 200 milliseconds, is never firing. Even though apparently plenty of calls are taking over a second in total, so what why is it slow? Are some of the synchronous functions we're calling slow?
72
+ - Basically, there's nowhere that could be slow, and we're timing it, and it times as being fast. However, in the profiles, it shows up as being slow.
73
+ - It could also be an asynchronous issue, so some other timing is getting alias to it. That is feasible...
72
74
  */
73
75
 
74
76
 
@@ -28,8 +28,6 @@ import { addComponentButton } from "../5-diagnostics/qreactDebug";
28
28
  import { closeAllModals } from "../5-diagnostics/Modal";
29
29
  import { delay } from "socket-function/src/batching";
30
30
 
31
- const ErrorWarning = createLazyComponent(() => import("./logs/errorNotifications/ErrorWarning"))("ErrorWarning");
32
-
33
31
  export const managementPageURL = new URLParam("managementpage", "");
34
32
  export const showingManagementURL = new URLParam("showingmanagement", false);
35
33
 
@@ -86,26 +84,11 @@ export async function registerManagementPages2(config: {
86
84
  controllerName: "NodeViewerController",
87
85
  getModule: () => import("./NodeViewer"),
88
86
  });
89
- inputPages.push({
90
- title: "Logs",
91
- componentName: "LogViewer2",
92
- getModule: () => import("./logs/LogViewer2"),
93
- });
94
87
  inputPages.push({
95
88
  title: "Logs3",
96
89
  componentName: "LogViewer3",
97
90
  getModule: () => import("./logs/IndexedLogs/LogViewer3"),
98
91
  });
99
- inputPages.push({
100
- title: "Life Cycles",
101
- componentName: "LifeCyclePages",
102
- getModule: () => import("./logs/lifeCycleAnalysis/LifeCyclePages"),
103
- });
104
- inputPages.push({
105
- title: "Error Digests",
106
- componentName: "ErrorDigestPage",
107
- getModule: () => import("./logs/errorNotifications/ErrorDigestPage"),
108
- });
109
92
  inputPages.push({
110
93
  title: "Security",
111
94
  componentName: "SecurityPage",
@@ -339,7 +322,6 @@ class ManagementRoot extends qreact.Component {
339
322
  `}
340
323
  </style>
341
324
  <div class={css.fillWidth.hbox(30, 10).wrap.hsl(245, 25, 60).pad2(10).pointerEvents("all")}>
342
- <ErrorWarning />
343
325
  {pages.map(page =>
344
326
  <ATag values={[{ param: managementPageURL, value: page.componentName }]}>{page.title}</ATag>
345
327
  )}
package/test.ts CHANGED
@@ -1,11 +1,6 @@
1
1
  import { Querysub } from "./src/4-querysub/QuerysubController";
2
2
  // Import querysub, so inject is run
3
3
  Querysub;
4
- import { formatTime } from "socket-function/src/formatting/format";
5
- import { getMachineId, getOwnMachineId } from "./src/-a-auth/certs";
6
- import { testLogs } from "./src/diagnostics/logs/LogViewer2";
7
- import { shutdown } from "./src/diagnostics/periodic";
8
- import crypto from "crypto";
9
4
  import { testMain } from "./testEntry2";
10
5
 
11
6
  testMain().catch(console.error).finally(() => {
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // public, so we can connect to it from any node (for diagnostics, etc)
4
- process.argv.push("--public");
5
- process.argv.push("--nobreak");
6
-
7
- require("typenode");
8
- require("../src/diagnostics/logs/errorNotifications/errorDigestEntry.tsx");
package/bin/error-im.js DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // public, so we can connect to it from any node (for diagnostics, etc)
4
- process.argv.push("--public");
5
- process.argv.push("--nobreak");
6
-
7
- require("typenode");
8
- require("../src/diagnostics/logs/errorNotifications/errorWatchEntry.tsx");