Skip to content

Support appending files with Bun.write #10473

Open

Description

@lsyuanyuan

What is the problem this feature would solve?

I read the document and the current way Bun writes files is:

const data = `It was the best of times, it was the worst of times.`;
await Bun.write("output.txt", data);

If new content needs to be added and written, then the node: fs module needs to be used,

import { appendFile } from "node:fs/promises";

await appendFile("message.txt", "data to append");

Is it being considered to add an optional parameter to Bun.write() or introduce a new method like Bun.appendWrite() to indicate appending new content? I feel this aligns well with Bun's inherent characteristics and makes it more concise

What is the feature you are proposing to solve the problem?

Add an optional parameter to Bun.write() or introduce a similar method Bun.appendWrite()

What alternatives have you considered?

Using the solution introduced in the official documentation

Activity

  1. added
    enhancement
    on Apr 24, 2024
  2. mangs commented on Apr 24, 2024

    @mangs
    Contributor
  3. added
    bun.js
    on Apr 24, 2024
  4. changed the title [-]Append writing new content when writing files[/-] [+]Support appending files with `Bun.write` [/+] on Apr 24, 2024
  5. changed the title [-]Support appending files with `Bun.write` [/-] [+]Support appending files with `Bun.write`[/+] on Apr 24, 2024
  6. gutenye commented on Apr 26, 2024

    @gutenye

    FileSink does not, it clears file content first before writing.

  7. mangs commented on Apr 26, 2024

    @mangs
    Contributor

    You're right, I realized that after I wrote this and forgot to come back and change this. Thank you for making this clear.

  8. added and removed
    bun.js
    on Jun 12, 2024
  9. VesperQuartz commented on Jun 16, 2025

    @VesperQuartz

    Yes we need this!

  10. KilianB commented on Aug 16, 2025

    @KilianB
    Contributor

    Appending to a file is such a common occurrence that at the end of the day I always have to fall back to the fs module.

  11. Atulin commented on Sep 16, 2025

    @Atulin

    Crazy that appending to a file is not a thing yet

  12. K-Mistele commented on Nov 17, 2025

    @K-Mistele

    +1, would love to see appending with filesink!

  13. 2 remaining items

  14. Atulin commented on Feb 22, 2026

    @Atulin

    The state of the issue, is that we'll be celebrating its 2nd anniversary in two months! 🎉

  15. nyxar77 commented on Feb 23, 2026

    @nyxar77

    The state of the issue, is that we'll be celebrating its 2nd anniversary in two months! 🎉

    i don't think i can live that long

  16. MrDanielHarka commented on Aug 21, 2026

    @MrDanielHarka

    I need this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bun:fsenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions