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

feat: implement database connection watcher #1270

Merged
merged 2 commits into from
May 5, 2024

Conversation

arthurgeron
Copy link
Contributor

@arthurgeron arthurgeron commented May 3, 2024

Description

  • There are situations where the DB is closed and doesn't fire a close/blocked event, so I've implemented an interval that doas a health check and attempts to restart otherwise;
  • Fixes extension side DB closing until extension reload after the Vault is locked, the browser hangs for a while and other edge cases scenarios where

Note: The DB is instantiated in both the extension's main thread and the service worker, we might want to refactor to instantiate and access it only in the service worker, using Chrome's Messaging API as a communication layer with the main thread. It'd be safer and less problematic to debug than having 2 connections.

Testing:

Reproducing the Error

I'd suggest going to the Send screen (first screen after clicking send), filling out the form, waiting for the extension's lock time, then clicking send.

You can also set a debugger point in useSend.tsx in devtools, in the first line of submit function; this forces a de-sync between the extension and service worker right before the auto lock (you'll still have to wait the auto-lock time out).

Expected behavior

  • Toast errors about DB connection shouldn't show continuously
  • The extension should work normally after unlocking.

@arthurgeron arthurgeron linked an issue May 3, 2024 that may be closed by this pull request
@arthurgeron arthurgeron requested a review from HoTandy May 3, 2024 23:03
Copy link
Contributor

github-actions bot commented May 3, 2024

Coverage report for ./packages/app

St.
Category Percentage Covered / Total
🟡 Statements 63.29% 3301/5216
🔴 Branches 41.58% 615/1479
🔴 Functions 47.57% 695/1461
🟡 Lines 63.88% 3184/4984

Test suite run success

246 tests passing in 73 suites.

Report generated by 🧪jest coverage report action from b2187d6

@luizstacio luizstacio merged commit 2752012 into master May 5, 2024
13 checks passed
@luizstacio luizstacio deleted the ag/fix/db-connection-closed branch May 5, 2024 02:11
luizstacio pushed a commit that referenced this pull request May 5, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to master, this PR
will be updated.


# Releases
## fuels-wallet@0.16.6

### Patch Changes

- [#1270](#1270)
[`27520126`](2752012)
Thanks [@arthurgeron](https://github.com/arthurgeron)! - fix: database
not recovering from error/closed state

-   Updated dependencies \[]:
    -   @fuel-wallet/connections@0.16.6

## @fuel-wallet/connections@0.16.6



## @fuel-wallet/types@0.16.6

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
arthurgeron added a commit that referenced this pull request May 6, 2024
Implements same fix as #1270  but without an interval.
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

Successfully merging this pull request may close these issues.

Indexed DB Errors
2 participants