I have the following code:
const request = require("request");
const data = {
    "url": "http://example.net/",
    "lenght": "(30 * 1000)"
};
(async () => {
    const r = request.get(data.url);
    let chank = 0;
    r.on("data", (data) => {
        chank += data.length;
        console.log("data", Math.round(chank / 1024), "kb");
    });
    setTimeout(() => {
        r.abort();
    }, eval(data.lenght));
    const token = await get_token();
    let o = {
        formData: {
            file: {
                value: r,
                options: {
                    filename: "d",
                    contentType: "audio/mpeg"
                }
            },
            token: token
        },
        json: true
    };
    const u = await new Promise((resolve) => { // <----
        request.post("https://www.other.co.il/api/UploadFile", o, (err, res, body) => {
            resolve(body);
        });
    });
    console.log(u);
})();
The code downloads the file from Server A, and uploads it streaming to Server B. After some time, the download from Server A aborts, and Server B is supposed to return a response.
The problem: The code is seemingly ok, but what usually happens, the node.js stops (at the line marked with a arrow), without informing an error.
The following line is never executed.
console.log(u);
The question is, what is wrong?
edit: This probably has to do with: https://stackoverflow.com/a/8636001/12054906
 
    