5 months ago
Occationally I get the Error below in my Railway server for When some of my users are accessing the the server. I've been trying to debug what the problem is but i can't.
BadRequestError: request aborted
at IncomingMessage.onAborted (/app/node_modules/raw-body/index.js:245:10)
at IncomingMessage.emit (node:events:517:28)
at IncomingMessage._destroy (node:_http_incoming:224:10)
at _destroy (node:internal/streams/destroy:109:10)
at IncomingMessage.destroy (node:internal/streams/destroy:71:5)
at abortIncoming (node:_http_server:781:9)
at socketOnClose (node:_http_server:775:3)
at Socket.emit (node:events:529:35)
at TCP. (node:net:350:12)
0 Replies
5 months ago
tell me more about the server you run on railway
It takes in a bunch of images and audio file and uses ffmpeg to convert the images and audios into one video file
5 months ago
what's the tech stack
5 months ago
how many replicas do you currently have
It works fine on my end and other users have no issues too most of the times. But occationally the error pops up
5 months ago
try adding a few more replicas
How many more would you suggest? And why does that solve the issue if you dont mind
5 months ago
start with 3 total,
a single node instance may not be able to handle all of the traffic.
5 months ago
a single node instance cannot use more than 1 vCPU since node is single threaded
Fair. After adding the replicas do i need to change any code or the allocation will be automatic?
5 months ago
we will run 3 instances of your app and handle the routing, as long as you don't store user state in memory you should be fine
5 months ago
that's up to you, do you have users from different locations?
5 months ago
wouldn't want to add replicas in locations you don't have any users
I do have users from different locations. Mostly Us/Europe , but i'll experiment with both and compare
5 months ago
sounds good!
But after turning on multiple replicas now , my server side events are not working
Usually i have SSE set up so that the progress of the video generation is sent from the nodejs server to the client constantly. But now the SSE does not work at all after turning on mutiple replicas
The server works fine and the video is generated successfully but the SSE updates does not show on the frontend. There is a browser error though
5 months ago
SSE does work with multi-region replicas, so this would be something with your code, what's the actual error? and are there errors in your deploy logs?
5 months ago
you have replicas in multiple regions
5 months ago
those are old deploy logs
5 months ago
ah I was just going off of this, either way, SSE fundamentally works with a single region or multi region replicas
In that case the issue might be something else. I'll debug. It might just be a coincedence that it started right after i added replicas
5 months ago
i would say that you are storing state in memory
5 months ago
the replica that is doing the ffmpeg stuff may not be the the replica that answered the SSE request
I'm not sure if i am storing state in memory or not. I don't know what that exactly means , but i'm using SSE to track the progress and send to the client
5 months ago
yeah then you are doing ffmpeg stuff on one instance and another instance doesn't know about it so SSE fails, you need to store the progress of a ffmpeg job globally in redis so that all replicas have access to the state of any ffmpeg job
5 months ago
it's just a guess from what you've told me, I could be wrong, please still do your own research
5 months ago
no problem!
5 months ago
!s
Status changed to Solved brody • 5 months ago