Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yaxy crashes on over 2Gb formData file uploads through HTTPS #32

Closed
amalitsky opened this issue Jan 10, 2020 · 2 comments
Closed

Yaxy crashes on over 2Gb formData file uploads through HTTPS #32

amalitsky opened this issue Jan 10, 2020 · 2 comments

Comments

@amalitsky
Copy link

First of all huge thanks for such a great tool, our UI development has been facilitated by it for years now. UI frameworks come and go but yaxy keeps working. We are planning to check webpack dev server in future but as of now we are good with what yaxy provides.

Not sure if project is maintained nor if this is worth fixing but seems like there is some limit of POST data size yaxy can handle when HTTPS is used (did not try wo HTTPS though). In our case 2.5Gb file upload is crashing yaxy.

Relevant part of configuration file:

$UseSSLFor development.loc

development.loc => https://localhost:8080/upload

File upload JS code:

function uploadFile() {
    const fileSelect = document.getElementById('file-select');

    if (!fileSelect.files) {
        return;
    }

    const [file] = fileSelect.files;
    const data = new FormData();

    data.append('file', file, file.name);

    const xhr = new XMLHttpRequest();

    xhr.onreadystatechange = () => {
        if (xhr.readyState === 4) {
            console.log(`request done, status: ${xhr.status}`);
        }
    };

    const api = '/upload';

    xhr.open('POST', api);
    xhr.send(data);
}

Back-end is very simple express nodejs server based on express-fileupload documentation examples.

Yaxy crash error stack:

RangeError [ERR_INVALID_OPT_VALUE]: The value “2698873595” is invalid for option “size”
    at Function.allocUnsafe (buffer.js:284:3)
    at Function.concat (buffer.js:464:25)
    at State.<anonymous> (/usr/local/lib/node_modules/yaxy/lib/yaxy.js:364:36)
    at /usr/local/lib/node_modules/yaxy/lib/yaxy.js:512:25
    at Array.forEach (<anonymous>)
    at State._onRequestEnd (/usr/local/lib/node_modules/yaxy/lib/yaxy.js:511:35)
    at IncomingMessage.emit (events.js:202:15)
    at endReadableNT (_stream_readable.js:1132:12)
    at processTicksAndRejections (internal/process/next_tick.js:76:17)

Upload works fine when yaxy is kept out of the loop. Also it works fine for 900Mb file through yaxy without any code/config changes.

Setting onprogress even listener on xhr.upload shows that whole file is being uploaded by the browser however load end event never happens. It looks like browser is closing request as time-out after more than 2 minutes with error code as empty response.

This nodejs ticket seems related but I'm no nodejs expert: nodejs/node#25057

P.S. Russian language is more than welcome, posting this in English so that everyone could find this issue.

@Kolyaj
Copy link
Owner

Kolyaj commented Jan 13, 2020

Моего английского, к сожалению, не хватает, чтобы связно выражаться, поэтому по-русски.

Похоже на то, что node не может создать такой большой Buffer, а я все чанки запроса перед проксированием зачем-то объединял в один. Выкатил версию 0.2.7 с отправкой данных без объединения в один Buffer. Должно полегчать.

P.S. Спасибо за благодарности :-)

@amalitsky
Copy link
Author

amalitsky commented Jan 17, 2020

Closing this as RESOLVED by 0.2.7! Thanks a lot for super fast turn around!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants