Skip to content

Throwing errors in module code breaks AMD loaders #182

@semmel

Description

@semmel

I load db.js as AMD module with RequireJS.
When a module throws an exception in it's module definition code the whole module loader breaks.
It occurs in this line:

var indexedDB = local.indexedDB || local.webkitIndexedDB || local.mozIndexedDB || local.oIndexedDB || local.msIndexedDB || local.shimIndexedDB || function () {
        throw new Error('IndexedDB required');
    }();

on Firefox if you disable third-party cookies in the settings and access indexedDB from a cross-origin iframe (i.e. simply load db.js via require(['db'], function(db){});. It will throw a SecurityError with code == 18.

I managed to hack around this, but it would be great if the exception would occur not till I actually access the db.js methods.

By the way, great api for IndexedDB. Small, concise and with Promises 👏 :bowtie:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions