@agoric/telemetry 0.6.3-dev-04140c1.0 → 0.6.3-dev-20168b0.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/telemetry",
3
- "version": "0.6.3-dev-04140c1.0+04140c1",
3
+ "version": "0.6.3-dev-20168b0.0+20168b0",
4
4
  "description": "Agoric's telemetry implementation",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/Agoric/agoric-sdk",
@@ -22,8 +22,8 @@
22
22
  "author": "Agoric",
23
23
  "license": "Apache-2.0",
24
24
  "dependencies": {
25
- "@agoric/internal": "0.3.3-dev-04140c1.0+04140c1",
26
- "@agoric/store": "0.9.3-dev-04140c1.0+04140c1",
25
+ "@agoric/internal": "0.3.3-dev-20168b0.0+20168b0",
26
+ "@agoric/store": "0.9.3-dev-20168b0.0+20168b0",
27
27
  "@endo/errors": "^1.2.10",
28
28
  "@endo/init": "^1.1.9",
29
29
  "@endo/marshal": "^1.6.4",
@@ -68,5 +68,5 @@
68
68
  "typeCoverage": {
69
69
  "atLeast": 88.87
70
70
  },
71
- "gitHead": "04140c18f9ad898cb4461e246c0065eddabb35ab"
71
+ "gitHead": "20168b0ba9fe3a1cf804b2fc91604abe4537a10a"
72
72
  }
@@ -283,20 +283,22 @@ export const makeSimpleCircularBuffer = async ({
283
283
  * @param {Pick<CircularBuffer, 'fileHandle' | 'writeCircBuf'>} circBuf
284
284
  */
285
285
  export const makeSlogSenderFromBuffer = ({ fileHandle, writeCircBuf }) => {
286
- /** @type {Promise<void>} */
286
+ /** @type {Promise<void> | undefined} */
287
287
  let toWrite = Promise.resolve();
288
288
  const writeJSON = (obj, serialized = serializeSlogObj(obj)) => {
289
289
  // Prepend a newline so that the file can be more easily manipulated.
290
290
  const data = new TextEncoder().encode(`\n${serialized}`);
291
291
  // console.log('have obj', obj, data);
292
- toWrite = toWrite.then(() => writeCircBuf(data));
292
+ toWrite = toWrite?.then(() => writeCircBuf(data));
293
293
  };
294
294
  return Object.assign(writeJSON, {
295
295
  forceFlush: async () => {
296
296
  await toWrite;
297
297
  },
298
298
  shutdown: async () => {
299
- await toWrite;
299
+ const lastWritten = toWrite;
300
+ toWrite = undefined;
301
+ await lastWritten;
300
302
  await fileHandle.close();
301
303
  },
302
304
  usesJsonObject: true,
@@ -35,7 +35,14 @@ const bufferTests = test.macro(
35
35
  fileHandle,
36
36
  writeCircBuf,
37
37
  });
38
- t.teardown(realSlogSender.shutdown);
38
+ let wasShutdown = false;
39
+ const shutdown = () => {
40
+ if (wasShutdown) return;
41
+ wasShutdown = true;
42
+
43
+ return realSlogSender.shutdown();
44
+ };
45
+ t.teardown(shutdown);
39
46
  // To verify lack of attempted mutation by the consumer, send only hardened
40
47
  // entries.
41
48
  /** @type {typeof realSlogSender} */
@@ -93,6 +100,18 @@ const bufferTests = test.macro(
93
100
  slogSender(null, 'PRE-SERIALIZED');
94
101
  await slogSender.forceFlush();
95
102
  t.truthy(fs.readFileSync(tmpFile).includes('PRE-SERIALIZED'));
103
+
104
+ slogSender(null, 'PRE_SHUTDOWN');
105
+ const shutdownP = shutdown();
106
+ slogSender(null, 'POST_SHUTDOWN');
107
+ await shutdownP;
108
+ slogSender(null, 'SHUTDOWN_COMPLETED');
109
+
110
+ const finalContent = fs.readFileSync(tmpFile);
111
+
112
+ t.truthy(finalContent.includes('PRE_SHUTDOWN'));
113
+ t.falsy(finalContent.includes('POST_SHUTDOWN'));
114
+ t.falsy(finalContent.includes('SHUTDOWN_COMPLETED'));
96
115
  },
97
116
  );
98
117