Hi everyone, I’m currently doing the Build a File Processor workshop. I’m running the workspace locally with Docker. I’m currently on lesson 27/30, but it won’t pass. Link to the workshop: https://www.freecodecamp.org/learn/back-end-development-and-apis-v9/workshop-build-a-file-processor/build-a-file-processor
THE LESSON 27 TASK:
Build a File Processor - Lesson 27
A stream lets you handle data incrementally without loading it all into memory. fs.createReadStream creates a readable stream that emits chunks of a file:
const fs = require(“fs”);
const readable = fs.createReadStream(“assets/poem.txt”, { encoding: “utf8” });
readable.on(“data”, (chunk) => {
console.log(chunk);
});
readable.on(“end”, () => {
console.log(“Done reading”);
});
In server.js, require fs and create a readable stream from ‘assets/poem.txt’ with encoding: ‘utf8’. Listen to the data and end events and log each chunk and a message when reading is complete.
Run node server.js - the poem should print in chunks, followed by your end message.
MY server dot js FILE CONTENT:
const fs = require("fs");
const readable = fs.createReadStream("assets/poem.txt", { encoding: "utf8" });
readable.on("data", (chunk) => {
console.log(chunk);
});
readable.on("end", () => {
console.log("Done reading");
});
THE LOG
node /workspaces/back-end-development-and-apis/build-a-file-processor (main) $ node server.js
Hello, freeCodeCamp!
Done reading
node /workspaces/back-end-development-and-apis/build-a-file-processor (main) $ node server.js
Hello, freeCodeCamp!
Done reading
node /workspaces/back-end-development-and-apis/build-a-file-processor (main) $
THE TESTS: test number 3 keeps failing
Tests
- ✓ server.js should call fs.createReadStream with ‘assets/poem.txt’.
- ✓ server.js should listen to the data event and the end event on the readable stream.
- ✗ Running server.js should print the poem contents to the console.
- ✓ You should run node server.js to see the console output.
NOTE: assets/poem.txt has a string content as you can see in the logs above. But it has probably changed from what it ws originally since I cloned the repo for the workshops because maybe 1 or more tasks from lessons 1-26 asked me to change the content of the file. I’m not sure about that though.
I have shut down and re-run the course multiple times from the command palette. and i’ve even closed and refreshed the docker to use a new container for the workspace but test number 3 still fails