Closed
Description
Version
v18.17.1
Platform
Win64
Subsystem
No response
What steps will reproduce the bug?
Run this script:
const fs = require("fs")
const path = require("path")
const { Readable } = require("stream")
const { finished } = require("stream/promises")
async function saveURLToFile(url, path) {
try {
const response = await fetch(url)
const fileStream = fs.createWriteStream(path)
await finished(Readable.fromWeb(response.body).pipe(fileStream))
} catch (err) {
console.log(err)
}
}
saveURLToFile("http://www.milicovice.cz/", path.resolve(__dirname, "output.html"))
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
The content (HTML page) is stored to the file.
What do you see instead?
The node crashes.
Additional information
This method works for other sites. It is unclear why this one is problematic. That error is apparently uncaught by the catch block.
This site belongs to the municipality of a small village. Please minimize the traffic (during testing) to a minimum. Thanks.