You are reading a single comment by @barbiani and its replies. Click here to read the full conversation.
  • Ha! Thank you. I used the forum search for "openfile" without results ;(

    Here is one solution to help other users.

    It fixes the heap leak, but still eventually fails to open the file.

        var f = E.openFile(a.pathname, "r");
        if (f !== undefined) { // File open succeeded - send it!
          res.writeHead(200, {'Content-Type': 'text/plain'});
          f.pipe(res, {chunkSize: 512,  complete: f.close});
        } else { // couldn't open file
          res.writeHead(404, {'Content-Type': 'text/plain'});
          res.end("404: Page "+a.pathname+" not found");

Avatar for barbiani @barbiani started