Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add failing test for reopening causing "Could not satisfy length" #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jmatsushita
Copy link

Hi there,

I've bumped into the following error:

Error: Could not satisfy length
    at RandomAccessIDB._read (http://localhost:54726/bundle.js:160:58)
    at Request._run (http://localhost:54726/bundle.js:7458:42)
    at drainQueue (http://localhost:54726/bundle.js:7511:48)
    at Request._unqueue (http://localhost:54726/bundle.js:7424:25)
    at Request.callback (http://localhost:54726/bundle.js:7429:10)
    at f (http://localhost:54726/bundle.js:6824:25)
    at RandomAccessIDB.onlen (http://localhost:54726/bundle.js:100:14)
    at f (http://localhost:54726/bundle.js:6824:25)
    at IDBRequest.req.onsuccess (http://localhost:54726/bundle.js:314:29)

I'm submitting a reproducer in a test simple-reopen.js. Note that I've had to wrap the reopening in a try/catch block as browser-run would just hang otherwise.

@jmatsushita
Copy link
Author

jmatsushita commented May 6, 2023

This seems to be because the this.length property is not initialised when opening an existing storage, so the (req.offset + req.size) > this.length check in _read fails.

@utanapishtim4storyboard
Copy link

Hey @jmatsushita thanks for opening this PR. I think the issue you are encountering is based on the assumption that the { storage } function exported from test/helpers.js acts like the static storage function implemented on the RandomAccessIDB class itself - it does not. The point of the test helper is to guarantee that even if we use the same filename, we get a totally unique IDB instance so we can test cleanly.

Try swaping { storage } from test helpers with const storage = RAI.storage() and see if that fixes your error.

@utanapishtim4storyboard
Copy link

@jmatsushita also, out of curiosity, are you npm installing the git repo? We should probably publish this to npm officially.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants