Skip to content

Readable.fromWeb is never finished #49233

Closed
@jan-tosovsky-cz

Description

@jan-tosovsky-cz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    streamIssues and PRs related to the stream subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions