Skip to content

Dexie Cloud: readBlobSync method fails in service worker environment #2182

@onuradsay

Description

@onuradsay

As XMLHttpRequest is not available in service worker environment, the code below throws Uncaught (in promise) ReferenceError: XMLHttpRequest is not defined error and the sync state becomes broken. This method is triggered when tryUseServiceWorker: true and there is a blob property in the table.

export function readBlobSync(b) {
    const req = new XMLHttpRequest();
    req.overrideMimeType("text/plain; charset=x-user-defined");
    req.open("GET", URL.createObjectURL(b), false); // Sync
    req.send();
    if (req.status !== 200 && req.status !== 0) {
        throw new Error("Bad Blob access: " + req.status);
    }
    return req.responseText;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions