You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What's the correct sequence of console log messages? The spec needs to be clarified. On Chrome, sometimes you see CHANGE+RESOLVED, and sometimes RESOLVED+CHANGE, which is confusing for developers.
In Firefox, the promise is always resolved before dispatching the CookieChangeEvent.
The text was updated successfully, but these errors were encountered:
bakulf
changed the title
CookieChangeEvent vs. promise resolve - what's the right order?
CookieChangeEvent vs. promise resolve - what's the correct order?
Sep 24, 2024
What if you end up calling set() multiple times? I wonder if this relates to #230 somehow.
Naively:
You call set()
It goes in parallel.
It stores something and knows that succeeded.
It now queues a task to a) resolve the promise and b) fire a change event.
As there is no JS on the stack, the event callbacks run before the promise callbacks?
Not sure if that's ideal though. I feel like the order between events and promises is still something we haven't really settled in general. cc @jakearchibald@domenic
It now queues a task to a) resolve the promise and b) fire a change event.
As there is no JS on the stack, the event callbacks run before the promise callbacks?
That's true for the first event callback, since events are dispatched synchronously. But since there's a microtask checkpoint after invoking a callback, the promise reaction callbacks are called after the first listener, but before the second (and third etc etc).
If you fire the event before resolving the promise, all event callbacks are called consistently before any of the promise reaction callbacks. That's why it's important to do events first.
What's the correct sequence of console log messages? The spec needs to be clarified. On Chrome, sometimes you see CHANGE+RESOLVED, and sometimes RESOLVED+CHANGE, which is confusing for developers.
In Firefox, the promise is always resolved before dispatching the
CookieChangeEvent
.The text was updated successfully, but these errors were encountered: