Skip to content

Reading a file after write returns an empty string #9522

Open
@khalidx

Description

@khalidx

What version of Bun is running?

1.0.33

What platform is your computer?

Linux aarch64 aarch64

What steps can reproduce the bug?

const dataFile = Bun.file('./data/some-file.json')

// Write the file
await Bun.write(dataFile, JSON.stringify({ timestamp: Date.now() }))

// Read the file
const data = await dataFile.text()

// The issue is here, data is an empty string
console.log(data)

What is the expected behavior?

The issue seems to be that writing a file, then immediately reading it afterwards returns an empty string, instead of the file contents. Maybe some stuff isn't getting flushed?

The data written to the file should be immediately available if a file is being read after a write.

Currently, if running the above steps twice, the first time will return an empty string, the second time will return the actual content of the file.

What do you see instead?

No response

Additional information

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingbun:fs

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions