Skip to content

[Safari] cookies.getAll() returns empty on the first call — storeId is left undefined, not a Cookie Store API issue #361

Description

@lunatech

Summary

On Safari, cookies.getAll() returns an empty array on the first call for a given tab/site, even though cookies exist. This is not the "Cookie Store API experimental feature" problem described in #355 — it's caused by querying with an unresolved storeId.

Root cause

Safari's WebExtension tabs API never populates tab.cookieStoreId (unlike Firefox). Code that calls cookies.getAll({ url, storeId: tab.cookieStoreId }) therefore always sends storeId: undefined. Safari 18+ has a documented regression where cookies.getAll() returns [] on the first invocation whenever the query resolves its cookie store implicitly instead of via an explicit, real store id.

Confirmed with instrumented logging on a Safari popup's first open:

storeId: undefined
count: 0

Confirmed against Apple's own developer forum reports of the same regression:

Suggested fix

Instead of the temporary-cookie workaround in #357 (which writes a zcookie-editor cookie into every site as a side effect), resolve real store ids first:

  1. Call cookies.getAllCookieStores().
  2. Call cookies.getAll({ ...query, storeId: store.id }) once per real store id returned, then merge the results.

This never passes an undefined storeId, and avoids creating a cookie as a side effect just to work around the bug.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions