15 Matching Annotations
  1. Nov 2023
  2. Feb 2023
    1. Session race conditions are very common in Rails. Redis session store doesn't help either! The reason is Rails only reads and creates the session object when it receives the request and writes it back to session store when request is complete and is about to be returned to user.
    1. As you can see from the example, the session cookie is updated on every request, regardless of if the session was modified or not. Depending on when the response gets back to the client last, thats the cookie that will be used in the next call. For example, if in our previous example, if get_current_result’s response was slower than get_quiz, then our cookie would have the correct data and the next call to update_response would of work fine! So sometimes it will work and sometimes not all depending on the internet gods. This type of race condition is no fun to deal with. The implications of this is that using cookie storage for sessions when you are doing multiple ajax call is just not safe.
    2. A better solution would be to use a server side session store like active record or memcache. Doing so prevents the session data from being reliant on client side cookies. Session data no longer has to be passed between the client and the server which means no more potential race conditions when two ajax are simultaneously made!
  3. Nov 2022
  4. Aug 2022
  5. Aug 2021
  6. Apr 2021
    1. To prevent race conditions and deadlocks, we highly recommend that each of the communication channels is serviced on a separate thread that maintains its own client buffer state and messaging queue inside your application. Servicing all of the pseudoconsole activities on the same thread may result in a deadlock where one of the communications buffers is filled and waiting for your action while you attempt to dispatch a blocking request on another channel.
  7. Feb 2021
    1. The rationale is that it's actually clearer to eager initialize. You don't need to worry about timing/concurrency that way. Lazy init is inherently more complex than eager init, so there should be a reason to choose lazy over eager rather than the other way around.
  8. Nov 2020
    1. But you can still run into strange race conditions where the browser displays stale data depending on if some other unrelated code has caused a digest update to run after the buggy code or not.
  9. Sep 2020
    1. export let client; setContext("client", client);

      Wouldn't this set context to undefined initially? And reassigning a new value to client wouldn't update the value stored in the context, would it? It would only update the let client variable.

      Where does this let client actually get set to the client from async function preload? I guess I need to understand Sapper more to know how this works, but it doesn't seem like it could.

      Update: I think I found the answer (it runs before):

      https://hyp.is/3aHeJgNFEeunkCsh8FVbDQ/sapper.svelte.dev/docs/

      It lives in a context="module" script — see the tutorial — because it's not part of the component instance itself; instead, it runs before the component is created, allowing you to avoid flashes while data is fetched.

    1. Handling race conditions (e.g. an earlier fetch() finishing after a later one, thus overriding download_count with an outdated value)
  10. Aug 2020