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

web installer should _wrapReq and return promise for idb transaction in saveFile #1132

Open
turbocrime opened this issue Mar 1, 2025 · 0 comments

Comments

@turbocrime
Copy link
Contributor

turbocrime commented Mar 1, 2025

problem

the installer page's BlobStore.download function awaits the return of async function BlobStore.saveFile,

await this.saveFile(filename, blob);

but saveFile performs no async operation:

async saveFile(name, blob) {
this.db.transaction(["files"], "readwrite").objectStore("files").add({
name: name,
blob: blob,
});
}

analysis

other locations using idb use the BlobStore._wrapReq helper to promisify transaction results, but saveFile does not use this helper.

so, saveFile effectively performs the synchronous operation of creating the transaction, and then returns immediately. this means the success or failure of this transaction does not resolve before return, and the download function proceeds with execution immediately regardless of the transaction state. the download function will proceed despite a transaction that is still pending or has failed.

specifically, if the saveFile transaction fails, the failure is not reported to the user or logged to the console. in this case, the web installer indicates a successful download of the factory image. the next step to flash the factory image will fail to retrieve the blob and instruct the user to download the factory image (which may fail again).

in my case, this was caused by a configuration to restrict all sites from storing data.

fix

use _wrapReq in saveFile so that download may await the resolution of the transaction as seems to be intended. this would surface failures, and actually await completion of the saving transaction.

suggestions

these additional things may be nice to have:

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

No branches or pull requests

1 participant