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

246
Visualizações
Chrome local storage is not storing dates correctly

When setting data in Chrome's local storage containing a date, all the data is correctly retrieved except the date that disappears, but I really don't know what I am doing wrong.

await browser.storage.local.remove("ghunt");
var payload = {"ghunt": {
                "cookies": "dummydata",
                "date": new Date(),
                "step": "login"
            }};
console.log("Raw payload => ", payload);
console.log("Putting the payload in local storage...")
await browser.storage.local.set(payload)
console.log("Retrieving data from local storage...")
var storage = await browser.storage.local.get("ghunt");
console.log("Retrieved data => ", storage);

The exact same code / commands works perfectly on Firefox.

PS : I am using WebExtension-Polyfill from Mozilla to provide cross-browser support

Firefox output screenshot
Chrome output screenshot

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

MDN on StorageArea.set() (emphasis mine):

It's generally not possible to store other types, such as Function, Date, RegExp, Set, Map, ArrayBuffer, and so on. Some of these unsupported types will restore as an empty object, and some cause set() to throw an error. The exact behavior here is browser-specific.

Store new Date().getTime(), which is an integer, not new Date().

about 4 years ago · Santiago Trujillo Relatório
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