All Questions
Tagged with node.js-fs asynchronous
98 questions
-4
votes
1
answer
52
views
Why does reading 10 50 MB files take the same amount of time as reading one 500 MB file in nodejs?
// fulfill one promise 5000ms
console.time('test');
(async function () {
await new Promise((resolve) => setTimeout(resolve, 5000));
console.log('slept')
})()
.then(() => {
console....
0
votes
1
answer
149
views
Using asynchronous Node.js functions with Python subprocesses
I have an app.js file that uses fs.watchFile() to check for changes in a text file. The changes are then outputed to the console. I have a python.py that I would like to use this JS file while the ...
-1
votes
1
answer
445
views
NodeJS - How to wait until fs.WriteStream is closed
I have some code that I need to wrap with mine, the original code is creating a WriteStream this way -
function createLog() {
this.stream = this.fs.createWriteStream(this.logFilePath, {flags: 'a'})...
1
vote
1
answer
694
views
How to await javascript fs.WriteStream close?
I am using nodejs pdfkit to create a pdf document that I save inside of a file.
I would like to write my pdf inside of a file and make sure that the pdf has finished writting before exiting my ...
0
votes
1
answer
146
views
No winston log files are created during pre-run check
I have a typescript project using winston and winston-daily-rotate-file. At the start of the project I check for environment variables that are present. If not, I want to log the missing variable ...
0
votes
1
answer
237
views
Using await with fs/promises function just exits code with no error
I am at a loss as to why I cannot read files inside a directory. I have tried every implementation of fs (both standard and promise-based). With the code below, the main function is called, logs "...
0
votes
0
answers
105
views
does running a synchronous function inside an async function make the function still run synchronously or will it make it run asynchronously? node.js
specfically when using fs.copyFilesync() and running it in an async function, will fs.copyFilesync() still run synchronously or will it run in an asynchronous manner like the fs.copyfile() function. ...
0
votes
2
answers
694
views
How to write multiple lines to a text file in a loop?
Within a javascript function, I'm taking in a list of events and for each event, I would like to write text to a file. I have provided the correct
// Code within another function
events.map(event =>...
1
vote
1
answer
21
views
ERR_HTTP_HEADERS_SENT caused by response to POST request after refresh node.js Express. res.send inside fs.watch callback
On my webpage user can enter text and press send. this causes the server to append the message to a json object stored in a file. when this file is altered it then sends the new json to the client.
...
1
vote
1
answer
153
views
How to use promises to asynchronously read directories and its contents node.js?
I'm trying to create a promise to check the contents of a certain directory in node. I believe I have an error with looping thats giving me an issue, im just not sure what it is.
var fileCheck = ...
0
votes
0
answers
15
views
How to wait for the callback to be finished with fs.readdir? [duplicate]
I'm using fs.readdir callback function to do stuff in a path file but i want to wait for the callback to be finished to continue on with the rest of my code.
const get = async(path_files) => {
...
0
votes
1
answer
638
views
Node/Typescript: How to close a writestream in the process 'exit' event - red/blue function problem / async infection
In my current FOSS Discord bot project I have this log.ts file which handles the logging for the bot.
It creates multiple fs.WriteStream objects, which write to each log file. There is a section in ...
0
votes
2
answers
263
views
Synchronicity problem: Wait until multiple fs.readFile calls complete
I want to read columns from different CSV files, and combine those columns into an array. I'm using fs.readFile to read the CSV files and a callback which processes the data and pushed a new element ...
0
votes
1
answer
26
views
Returning object from json file search
I'm trying to verify if an incoming request matches a player database, then returning it to a function that will later change the data.
it always returns undefined or false.
I've tried moving the ...
4
votes
2
answers
2k
views
Read and Write files from 'fs' not working asynchronously
I am trying to build a script which read and write some files. The functions are working fine but I am having trouble making the read/write functions asynchronously. The main problem I have is that I ...