Openbravo Issue Tracking System - POS2
View Issue Details
0046831POS2Corepublic2021-05-25 15:592021-06-02 12:43
alostale 
gorka_gil 
normalmajorhave not tried
closedfixed 
5
 
 
No
0046831: error when updating sources
When sources are updated state database is deleted, this step throws an error that can be seen in console.
Serving in production mode

1. Login pos2
2. Update sources and deploy the production bundle
3. Reload pos2
  -> ERROR: check console

POS2.js:3247 Error: Cannot drop database POS2_state because request is blocked
    at IDBOpenDBRequest.<anonymous> (http://localhost:8181/openbravo/web/pos/static/js/12.3c2e1da5.chunk.js:1:101307 [^]); line: Ee (0.92304dcb.chunk.js:1) (*)
No tags attached.
related to defect 0046498 closed alostale POS2 New sources are not updated till doing a reload (F5) in the pos 
depends on backport 0046895TAP closed gorka_gil POS2 error when updating sources 
related to defect 0046938 closed gorka_gil Retail Modules error when updating sources - pos1 
Issue History
2021-05-25 15:59alostaleNew Issue
2021-05-25 15:59alostaleAssigned To => Retail
2021-05-25 15:59alostaleTriggers an Emergency Pack => No
2021-05-25 16:00alostaleRelationship addedrelated to 0046498
2021-05-25 16:01alostaleResolution time => 1623708000
2021-05-26 07:10alostaleAssigned ToRetail => platform
2021-05-26 07:10alostaleStatusnew => acknowledged
2021-05-28 13:17alostaleAssigned Toplatform => gorka_gil
2021-05-28 13:17alostaleIssue Monitored: alostale
2021-05-28 22:19guilleaerStatusacknowledged => scheduled
2021-05-31 19:57hgbotNote Added: 0128825
2021-06-01 13:25hgbotNote Added: 0128857
2021-06-01 13:25hgbotNote Added: 0128858
2021-06-01 18:44gorka_gilRelationship addedrelated to 0046938
2021-06-02 12:43alostaleStatusscheduled => resolved
2021-06-02 12:43alostaleResolutionopen => fixed
2021-06-02 12:43alostaleStatusresolved => closed

Notes
(0128825)
hgbot   
2021-05-31 19:57   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.core2/-/merge_requests/528 [^]
(0128857)
hgbot   
2021-06-01 13:25   
Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.core2 [^]
Changeset: 6a29db215e1e5701bf84c7239c36593816b12dd6
Author: Gorka Gil <gorka.gil@openbravo.com>
Date: 2021-06-01T12:16:15+02:00
URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.core2/-/commit/6a29db215e1e5701bf84c7239c36593816b12dd6 [^]

Fix ISSUE-46831: delete the state on sources update in a better way

Make use of the api to reset the state

It is the more secure way to delete the state, removing a property of localstorage,
after the reload, the ram is deleted so the state of the ram is lost.
Then it will try to reload the state from disk, but before do that, will check if the
localstorage property exists and if not, will delete the disk state db before try to
load it.

In this way we don't try to delete a running state and there is no race conditions that
can cause problems.

Other discarded options:

a) With indexeddb api, delete the db of the state:
  const persistenceDB = new OB.App.Class.IndexedDBController('state');
  persistenceDB.deleteDatabase().finally(() => {
    window.location.reload();
  });
  - Problem: it deletes an db is use, gives an error that can not be deleted,
  but in any case looks like working, but doesn't look to have the error,
  also doesn't give security that will work always. Also doesn't ensure that
  after delete and before the reload the db is saved again

b) Purge db with localforage api:
  OB.App.State.getPersistence().stateStorePersistor.purge()
  It can be used since a recent change that ensures that state is started
  before the check of sources.
  - Problem: It works on F5, but not in logut/login not clear why.

c) New state action that clear the state:
  Tested but looks like is not working, not clear why but the state is not reset
  maybe some protection in the code.
  In any case will probably launch the listeners of the state, and since all the
  spected variables are not there very probably will produce errors.

---
M web-jspack/org.openbravo.core2/src/registerServiceWorker.js
---
(0128858)
hgbot   
2021-06-01 13:25   
Merge request merged: https://gitlab.com/openbravo/product/pmods/org.openbravo.core2/-/merge_requests/528 [^]