Disk I/O errors with OPFSCoopSyncVFS #290
-
One of our PowerSync users recently reported In this scenario the reported number of bytes written is much larger than the buffer provided to be written. From testing the reported number of bytes seems to consistently be reported as The PowerSync SDK eventually retries this operation and does eventually succeed to write the data to the VFS. The reported user managed to create a relatively simple reproducible example here. The issue is not reproducible 100% of the time. I have only been able to intermittently reproduce, when using a fresh DB between retries. I was able to capture the following logs when running the reproducible example in Chrome (running under Playwright)
I added some basic logs to the jWrite(fileId, pData, iOffset) {
try {
const file = this.mapIdToFile.get(fileId);
// On Chrome (at least), passing pData to accessHandle.write() is
// an error because pData is a Proxy of a Uint8Array. Calling
// subarray() produces a real Uint8Array and that works.
const accessHandle = file.accessHandle || file.persistentFile.accessHandle;
const nBytes = accessHandle.write(pData.subarray(), { at: iOffset });
if (nBytes !== pData.byteLength) {
debugger
console.log(`${nBytes} !== ${pData.byteLength}`)
console.log(iOffset)
console.log(accessHandle)
console.log(file)
throw new Error('short write')
};
return VFS.SQLITE_OK;
} catch (e) {
this.lastError = e;
return VFS.SQLITE_IOERR_WRITE;
}
} ![]() I'm not quite sure if this might be a browser related issue, or under which circumstances the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
You're using your own fork, right? Can you tell me whether you have the commits from #285 in your fork? Whatever version you have, can you try to reproduce the problem the other way - i.e. if you don't have those commits then add them, and if you have those commits then revert them. That PR changes the wrapper for the |
Beta Was this translation helpful? Give feedback.
I had this backwards. It is
nBytes
, the return value fromFileSystemSyncAccessHandle.write()
, that is2^32 - 8
. And that I have seen before here. It is a browser bug that Chrome is returning an error code cast to a 64-bit integer when it should be throwing some sort of exception, but the underlying cause is exceeding available disk space (either physical space or quota). I think your issue is related to this, and may be exactly this.Is it possible that all these failures are happening in incognito mode? Note that the storage quota reported will not reflect the incogni…