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

fix: Error in web context when window.indexedDB API is available but protected #2039

Merged
merged 2 commits into from
Oct 7, 2023

Conversation

dplewis
Copy link
Member

@dplewis dplewis commented Oct 6, 2023

Pull Request

Issue

In a web context where window.indexedDB is protected from use but does exists, Parse SDK throws an error on initial import

Closes: #2038

Approach

  • Lazy Load Parse.IndexedDB
  • Allow for custom IndexDB StorageController
  • Handle errors on initialize

Tasks

  • Add tests
  • Add changes to documentation (guides, repository pages, code comments)

@parse-github-assistant
Copy link

Thanks for opening this pull request!

@codecov
Copy link

codecov bot commented Oct 6, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (3bf55f6) 100.00% compared to head (acc66a4) 100.00%.

❗ Current head acc66a4 differs from pull request most recent head 5859165. Consider uploading reports for the commit 5859165 to get more accurate results

Additional details and impacted files
@@            Coverage Diff            @@
##             alpha     #2039   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           61        61           
  Lines         6176      6178    +2     
  Branches      1496      1496           
=========================================
+ Hits          6176      6178    +2     
Files Coverage Δ
src/IndexedDBStorageController.js 100.00% <100.00%> (ø)
src/Parse.ts 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dplewis dplewis requested a review from mtrezza October 6, 2023 18:21
@dplewis dplewis changed the title fix: Error when IndexedDB is defined but is protected fix: Error when IndexedDB is defined but protected Oct 6, 2023
Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@mtrezza mtrezza changed the title fix: Error when IndexedDB is defined but protected fix: Error in web context when window.indexedDB API is available but protected Oct 6, 2023
@mtrezza
Copy link
Member

mtrezza commented Oct 6, 2023

@westhom do you want to try out this PR before we merge it, so we know it fixes the issue you reported?

@westhom
Copy link

westhom commented Oct 6, 2023

Thanks for the quick fix @dplewis .

@mtrezza Can you advise on the best way of testing? I'm having issues with my build pipeline, that I don't see with the npm published package. This is what I'm doing:

  1. checkout dplewis fix branch
  2. npm run watch:browser (no errors)
  3. cd to my project repo, and npm link ../Parse-SDK-JS/
  4. I've tried importing parse with both import Parse from 'parse' and import Parse from 'parse/dist/parse.min.js
  5. When I build my project I get the error 'default' is not exported by ../Parse-SDK-JS/index.js, imported by ui-src/App.tsx

The fix looks like it should work but currently unable to test.

@mtrezza
Copy link
Member

mtrezza commented Oct 7, 2023

No worries, @westhom, we'll make an alpha release so you can test this out easier; the PR already has a passing test, so we can assume it works; your issue #2038 will be automatically closed; if you still encounter any issues please let us know and we can re-open it.

@mtrezza mtrezza merged commit 360981f into parse-community:alpha Oct 7, 2023
7 checks passed
parseplatformorg pushed a commit that referenced this pull request Oct 7, 2023
# [4.3.0-alpha.4](4.3.0-alpha.3...4.3.0-alpha.4) (2023-10-07)

### Bug Fixes

* Error in web context when `window.indexedDB` API is available but protected ([#2039](#2039)) ([360981f](360981f))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 4.3.0-alpha.4

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Oct 7, 2023
@dplewis
Copy link
Member Author

dplewis commented Oct 7, 2023

@westhom No problem! I got it done fast because it was on my list. Let me know if you have more issues with Figma plugins. I don’t know what that is lol

@dplewis dplewis deleted the indexeddb-protected branch October 7, 2023 07:06
@westhom
Copy link

westhom commented Oct 11, 2023

@dplewis I can confirm that the latest parse@alpha release via npm is now importable inside Figma web context! Thx for the quick fix.

parseplatformorg pushed a commit that referenced this pull request Nov 16, 2023
## [4.3.1-beta.1](4.3.0...4.3.1-beta.1) (2023-11-16)

### Bug Fixes

* Connection failure in `Parse.Object.saveEventually` and `Parse.Object.destroyEventually` not handled on custom `Parse.Error.CONNECTION_FAILURE` message ([#2032](#2032)) ([4da3ebc](4da3ebc))
* Docs fail with `Cannot find module 'taffydb'` ([#2036](#2036)) ([dc91d0f](dc91d0f))
* Error in web context when `window.indexedDB` API is available but protected ([#2039](#2039)) ([360981f](360981f))
* Security upgrade browserify-sign from 4.2.1 to 4.2.2 ([#2043](#2043)) ([fd50b9d](fd50b9d))
* Security upgrade crypto-js from 4.1.1 to 4.2.0 ([#2042](#2042)) ([681fbdf](681fbdf))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 4.3.1-beta.1

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Nov 16, 2023
parseplatformorg pushed a commit that referenced this pull request Nov 18, 2023
## [4.3.1](4.3.0...4.3.1) (2023-11-18)

### Bug Fixes

* Connection failure in `Parse.Object.saveEventually` and `Parse.Object.destroyEventually` not handled on custom `Parse.Error.CONNECTION_FAILURE` message ([#2032](#2032)) ([4da3ebc](4da3ebc))
* Docs fail with `Cannot find module 'taffydb'` ([#2036](#2036)) ([dc91d0f](dc91d0f))
* Error in web context when `window.indexedDB` API is available but protected ([#2039](#2039)) ([360981f](360981f))
* Security upgrade browserify-sign from 4.2.1 to 4.2.2 ([#2043](#2043)) ([fd50b9d](fd50b9d))
* Security upgrade crypto-js from 4.1.1 to 4.2.0 ([#2042](#2042)) ([681fbdf](681fbdf))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 4.3.1

@parseplatformorg parseplatformorg added the state:released Released as stable version label Nov 18, 2023
parseplatformorg pushed a commit that referenced this pull request Nov 18, 2023
## [4.3.1-alpha.1](4.3.0...4.3.1-alpha.1) (2023-11-18)

### Bug Fixes

* Connection failure in `Parse.Object.saveEventually` and `Parse.Object.destroyEventually` not handled on custom `Parse.Error.CONNECTION_FAILURE` message ([#2032](#2032)) ([4da3ebc](4da3ebc))
* Docs fail with `Cannot find module 'taffydb'` ([#2036](#2036)) ([dc91d0f](dc91d0f))
* Error in web context when `window.indexedDB` API is available but protected ([#2039](#2039)) ([360981f](360981f))
* Security upgrade browserify-sign from 4.2.1 to 4.2.2 ([#2043](#2043)) ([fd50b9d](fd50b9d))
* Security upgrade crypto-js from 4.1.1 to 4.2.0 ([#2042](#2042)) ([681fbdf](681fbdf))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 4.3.1-alpha.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version
Projects
None yet
4 participants