Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

194
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda