31

Just spent hours, debugging why a system is creating two objects in the database when trying to create one.

Turns out it is Chrome re-sending a POST request.

Really.

What. The. Actual. Fuck. Google.

Comments
  • 7
    You sure your front end logic isn't doing it? Isn't the first request a cord request and creates the object anyway since you don't check for the http method?
  • 0
    @EngineerCoding I seem to remember running into this a couple months ago, and I think you're right
  • 0
    Chrome sometimes does this if your server does not respond fast enough. Or maybe your front end had bind the event twice on the same DOM object.
  • 1
    Google Chrome, stealing all yo personal data one unnoticeable POST request at a time 👌
  • 0
    ive seen this bug on chrome randomly on some of my web apps. I havent find out a real solution yet.
  • 1
    @gdb123 this is the type of thing Google calls a feature.
  • 5
    Are you checking for the http method, as per the CORS standard a lightweight [OPTION] request is sent before every request to check the waters. Option requests however dont send data in the body, they do however send url params, cookies and so forth
  • 2
    @gdb123 It is not a bug.
    Whenever you are sending an XHR / Fetch request to a domain which is not the same which rendered the initial page (that is how it usually is with rest spa apps) chrome sends one OPTIONS request including CORS data and the methods it wanted to perform.

    Server needs to respond with 200 OK and valid CORS response before the browser will make the actual request.

    It's a safety feature :)
  • 0
    Idempotency isn't just a crater on mars
  • 0
    Idempotency to the rescue!
Add Comment