Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

195
Visualizações
socket.io POST error and CORS policy error when sending messages too fast

In my frontend app I implemented mechanism which splits file into chunks and then sends their parts in a for loop like this (chunks is an array of strings - contents of file in binary form):

for (let i = 0; i < chunks.length; i++) {
  sendFile(chunks[i], name, extension, mimeType, chunks.length, i);
}

It wasn't working though. I was getting this error: enter image description here

So I thought - maybe I'll add a delay between each chunk emit and ye - it worked. If server is hosted on localhost, 20ms interval is enough:

for (let i = 0; i < chunks.length; i++) {
  sendFile(chunks[i], name, extension, mimeType, chunks.length, i);
  await sleep(20);
}

Now I deployed app to my VPS and error is back. I noticed that I had to increase sleep duration to 100ms for it to work.

What is causing this and how to address this issue?

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

Seems like long-polling transport method just sucks in general. Always aim to use websockets - it resolved my issue.

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda