Does nginx work with streamed HTTP responses?

For one of our endpoints, we decided to return a stream instead of a response, to download a CSV file.

const stream = await claimProjectionsRepository.exportClaims({
    filter,
    sortBy,
    sortDir,
});

response.writeHead(200, {
    'Content-Disposition': `attachment; filename=cases.csv`,
    'Content-Type': 'text/csv; charset=UTF-8',
});
stream.pipe(response);
stream.on('end', () => response.end());

stream.on('error', (error) => {
    logger.error({
        event: 'export.claims',
        message: 'stream error',
        success: false,
        stack: error,
        error,
    });
});

This endpoint works fine locally and within a Docker container.

But as soon as we deploy it to Qovery-managed cluster, this endpoint times out and fails in a 504 Gateway Timeout after 60s (the configured nginx read timeout).
I’ve tried to increase the nginx timeout to 10min, it’s just failing after the timeout duration.

Is there something we are missing in the Nginx configuration that prevents streamed HTTP-response to work with Qovery clusters?

For reference, here is our configuration:

Advanced Configuration

1 Like

Hello Kevin,

Do you mind sharing the console url of your application ? So we can take a look at it

Here is it: Qovery

I made some change for this app, can you retry your endpoint and let me know if it helps ?