Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite committed Feb 22, 2024
1 parent 212d4ed commit 2755d03
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class SessionManagerV3 {
return manager
}

private async save(): Promise<void> {
private async syncMetadata(): Promise<void> {
if (this.buffer) {
await writeFile(this.file('metadata.json'), JSON.stringify(this.buffer?.context), 'utf-8')
} else {
Expand Down Expand Up @@ -205,12 +205,12 @@ export class SessionManagerV3 {
buffer.context.count += 1
buffer.context.sizeEstimate += content.length

await this.save()

if (!buffer.fileStream.write(content, 'utf-8')) {
writeStreamBlocked.inc()
await new Promise((r) => buffer.fileStream.once('drain', r))
}

await this.syncMetadata()
} catch (error) {
this.captureException(error, { message })
throw error
Expand Down Expand Up @@ -296,7 +296,7 @@ export class SessionManagerV3 {
await rename(this.file(BUFFER_FILE_NAME), this.file(fileName))
this.buffer = undefined

await this.save()
await this.syncMetadata()
}

private async flushFiles(): Promise<void> {
Expand Down

0 comments on commit 2755d03

Please sign in to comment.