Files in deployments are weird

Hmm, I’m not sure of that. I have an application deployed and I’m able to generate files using fs.writeFile, for example. However, I’m not sure how long that file is kept, because I usually generate them, do my work and delete it later.
For example:

const express = require("express");
const fs = require("node:fs");
const app = express();

app.get("/test", async (req, res) => {
  const request = await fetch("https://jsonplaceholder.typicode.com/users");
  const response = await request.json();
  // console.log(response);

  fs.writeFileSync("./test/list.json", JSON.stringify(response, null, 2));
  console.log("File created!");
  setTimeout( () => {
    fs.unlinkSync("./test/list.json");
    console.log("File deleted");
  }, 30000); // 30 seconds

  res.status(200).send('File Created');  
})

After generating the file, I can even access it via https://my_deployed_url/test/list.json.

Based on your code, you shouldn’t be able to access /test/list.json via your deployed url. A full repl link would provide necessary context for this.

Also, please make a new bug report, since similar-looking issues will almost always be caused by completely different catalysts.

2 Likes

In addition, the file system does work, it just resets everytime the repl restarts (aka ephemeral fs)