Skip to content

Commit

Permalink
fixup! feat: simple CircularBuffer with fs offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Feb 13, 2024
1 parent 3860eed commit 8780610
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/telemetry/src/flight-recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,18 +272,18 @@ export const makeSimpleCircularBuffer = async ({
* @param {Pick<Awaited<ReturnType<typeof makeSimpleCircularBuffer>>, 'writeCircBuf'>} circBuf
*/
export const makeSlogSenderFromBuffer = ({ writeCircBuf }) => {
let writes = [];
let toWrite = Promise.resolve();
const writeJSON = (obj, serialized = serializeSlogObj(obj)) => {
// Prepend a newline so that the file can be more easily manipulated.
const data = new TextEncoder().encode(`\n${serialized}`);
// console.log('have obj', obj, data);
writes.push(writeCircBuf(data));
toWrite = toWrite.then(() => writeCircBuf(data));
};
return Object.assign(writeJSON, {
forceFlush: async () => {
const flushing = [...writes];
writes = [];
return Promise.all(flushing).then(() => {});
const writing = toWrite;
toWrite = Promise.resolve();
await writing;
},
usesJsonObject: true,
});
Expand Down

0 comments on commit 8780610

Please sign in to comment.