uNetworking / uWebSockets.js

μWebSockets for Node.js back-ends :metal:
Apache License 2.0
7.86k stars 569 forks source link

First request, if send with body takes forever #756

Closed dominikzogg closed 2 years ago

dominikzogg commented 2 years ago

I work on a implementation to run my typescript web framework with uwebsockets. Without one expection its running great so far. After started the server a request without a request body (res.onData) works well. After started the server a request with a request body (res.onData) takes forever. If the second call got a request body i got no issue at all.

I have no idea if i do something wrong.

https://github.com/chubbyts/chubbyts-uwebsockets-http-bridge/blob/master/src/uwebsocket-http.ts#L66

e3dio commented 2 years ago

Who knows what your code is doing. You are asking to debug your code which spans multiple repositories, what is streamFromResourceFactory doing? Do you know how to do basic testing?

dominikzogg commented 2 years ago

Hi @e3dio

https://github.com/chubbyts/chubbyts-http/blob/master/src/message-factory.ts#L40 But the code behaves the same without calling it.

I guessed it's a known issues in using the library, thats why i ask. Using the default node server with the same code (except the code in uwebsocket).

The stream created (by me, based on res.onData) won't receive any data or get to an end in the first request after the start.

const readStream = async (stream) => {
    return new Promise((resolve, reject) => {
        let data = '';

        stream.on('data', (chunk) => { data += chunk; console.log(data); });
        stream.on('end', () => resolve(data));
        stream.on('error', (error) => reject(error));
    });
};
e3dio commented 2 years ago

If you need help you should post complete simplified example and explain how you are testing making posts, preferably not in typescript and not across 3 different repos. Your onAborted function does nothing when it should be doing something