question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Storage not persisting on Chrome and Firefox

See original GitHub issue

Apparently there’s an error: DOMException: "The operation failed because the requested database object could not be found. For example, an object store did not exist but was being opened."

Gonna figure this out on Monday.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
RangerMauvecommented, Jul 29, 2019

Are you sure Chrome isn’t persisting storage? It uses the filesystem API instead if IDB for persistence. It’d likely error out if it had trouble writing stuff, too.

I’m not sure how we can handle deleting parts of IndexedDB, I think the storage layer has a particular way of interacting with it, so there should probably be an API for deletion there instead of deleting it externally.

Does fully deleting IDB and refreshing the page help?

1reaction
ImVexedcommented, Jul 28, 2019

Repro: From a new create-react-app: yarn add dat-sdk

App.js

import React from 'react';
import './App.css';
import { getImage } from './p2p';


export default class extends React.Component {

  async componentDidMount() {
    this.setState({ img: await getImage('bklqtanmv35ek46ujnk0') })
  }

  render() {
    return (
      <div className="App">
        <header className="App-header">
          <img src={this.state ? this.state.img : null} className="App-logo" alt="logo" />
          <p>
            Edit <code>src/App.js</code> and save to reload.
          </p>
          <a
            className="App-link"
            href="https://reactjs.org"
            target="_blank"
            rel="noopener noreferrer"
          >
            Learn React
          </a>
        </header>
      </div>
    );
  }
}

p2p.js

const { Hyperdrive } = require('dat-sdk')();

export const archive = Hyperdrive('dat://61382211b2ee66635949138ab0161e409b6788704954cb31739d6b7d4acc0162', { persist: true })

archive.on('error', console.error)

export async function getImage(uid) {
    return await fetchFile(uid, 'image.raw.webp');
}

async function fetchFile(uid, file) {
    const stream = archive.createReadStream(`/${uid}/${file}`)

    let chunks = [];

    const data = await new Promise((resolve, _) => {
        stream.on('data', function (chunk) {
            chunks.push(chunk)
        }).on('end', function () {
            resolve(URL.createObjectURL(new Blob(chunks, { type: 'image/webp' })))
        }).on('error', console.error)
    })

    return data;
}

Works initially in the browser loading an image, however, after you delete either the Dat folder or IDBMutableFile inside the Indexed DB tab of Firefox it will either fail silently or give the DOMException.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Browser.storage.local is not persistent - Mozilla Discourse
As long as you are using browser.storage.local.set() to save items to the storage, it should be persistent. If you are loading it as...
Read more >
How can I fix the local storage issue in my browser? - Hipporello
If the problem persists: · Click on the three dots icon at the top right. · Click "Settings". · Click "Advanced". · Select...
Read more >
Persistent local storage for both Firefox and Chrome?
You can store far more than 50 MB in IndexedDB in both Firefox and Chrome, assuming the user has enough hard drive space....
Read more >
Local Storage not showing data : r/firefox - Reddit
Firefox Developer Tools : Storage : Local Storage is unpopulated but a console.log(localStorage); proves the code is working. Like upthepowerx ...
Read more >
How-to: View Local Storage in Chrome and Firefox - UI Vision
And as the same suggests, all is saved locally on the machine where the browser is installed. Local storage is not in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found