Skip to content

Commit

Permalink
replayio: add trailing newline to recordings.log (#508)
Browse files Browse the repository at this point in the history
  • Loading branch information
hbenl authored Jun 5, 2024
1 parent 4954cd1 commit e0ce74f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/replayio/src/utils/recordings/readRecordingLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export function readRecordingLog() {
} catch (err) {
debug(`Error parsing line:\n${line}`);

// Early versions of `replayio` could remove the trailing \n from recordings.log,
// so the next entry would be appended to the last line, creating a line with two
// entries. This workaround lets us read these corrupted entries but it should
// be removed eventually.
const replaced = line.replace(/\}\{/g, "}\n{");

if (replaced.length === line.length) {
Expand Down
2 changes: 1 addition & 1 deletion packages/replayio/src/utils/recordings/removeFromDisk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function removeFromDisk(id?: string) {

writeFileSync(
recordingLogPath,
filteredLogs.map(log => JSON.stringify(log)).join("\n"),
filteredLogs.map(log => JSON.stringify(log)).join("\n") + "\n",
"utf8"
);
} else {
Expand Down

0 comments on commit e0ce74f

Please sign in to comment.