Skip to content

SDK throws error in web contexts where calling into window.indexedDB is prohibited, but not undefined on the window #2038

Closed
@westhom

Description

@westhom

New Issue Checklist

Issue Description

In a web context where window.indexedDB is protected from use but not undefined, Parse SDK throws an error on initial import. For example, in a Figma Plugin web context, window.indexedDB API is defined, but once an indexedDB API function is called an error is thrown:

Uncaught DOMException: Failed to execute 'open' on 'IDBFactory': access to the Indexed Database API is denied in this context.

Parse is an initializing an indexedDB store in this file, to store at top level property Parse.IndexDB, even if the user never sets the Parse storage controller to indexedDB.

3 fix options immediately come to mind:

  1. Wrap line linked above in try/catch, and set Parse.IndexedDB to undefined if it throws
  2. Don't initialize Parse.IndexedDB store by default, since it isn't used by default.
  3. Remove IndexedDBStorageController from Parse SDK to a plugin module, or example file. It would also clean up the unused idb-keyval dependency.

Steps to reproduce

Create a figma plugin and import the Parse library:

import Parse from 'parse/dist/parse.min.js' // error thrown

Actual Outcome

Parse cannot be imported.

Expected Outcome

Parse can be imported.

Environment

Server

  • Parse Server version: n/a
  • Operating system: n/a
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): n/a

Database

  • System (MongoDB or Postgres): n/a
  • Database version: n/a
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): n/a

Client

  • Parse JS SDK version: 4.2.0

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions