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

188
Visualizações
Failed browser "fetch" causes second unrelated fetch to fail

I've stumbled about a strange bug that I can't wrap my head around.

In an application I'm working on, due to an error, a fetch with a way to big URL was triggered. Because that fetch is so big it fails (414 - request entity too large).

All fine up to this point.

Now, due to a completely unrelated part of the application, a second fetch was made to the same API. Strangely this second, unrelated fetch fails too.

I created a minimal reproduction for it to find out what causes this weird behaviour. It turns out it only happens with the following criteria:

  • Second fetch must request the same API
  • Second fetch must happen in a certain time period (setTimeout with short delay also fails, but if you increase that value, at some point the issue disappears)

This behaviour seems to be reproducible on all major browsers. I used mainly chrome.

Code that illustrates issue:

import { useEffect, useState } from "react";

function App() {
  const [counter, setCounter] = useState(0);

  useEffect(() => {
    // way to big fetch
    fetch(
      "https://catfact.ninja/fact/failurefetch?long=INSERT_ABSURDLY_LONG_STRING_RIGH_HERE_THAT_REACHES_URL_LIMIT",
      { method: "GET" }
    ).then((res) => res.json());
  }, [counter]);
  useEffect(() => {
    // fails
    fetch("https://catfact.ninja/fact", { method: "GET" });
    // also fails
    setTimeout(() => {
      fetch("https://catfact.ninja/fact", { method: "GET" });
    }, 10);
    // works
    setTimeout(() => {
      fetch("https://catfact.ninja/fact", { method: "GET" });
    }, 1000);
  }, [counter]);

  return (
    <div
      className="App"
      onClick={() => {
        setCounter((prev) => prev + 1);
      }}
    >
      Refetch
    </div>
  );
}

export default App;

Reproduction codesandbox

about 4 years ago · Juan Pablo Isaza
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