Openbravo Issue Tracking System - POS2
View Issue Details
0050314POS2Corepublic2022-09-22 16:212022-10-11 12:25
cberner 
cberner 
normalmajorhave not tried
closedfixed 
5
 
23Q1 
AugustoMauch
No
0050314: State compression on occasions breaks the state on deployed pos2
If we refresh pos2 without any previous state and no data of the application, it breaks with the following error continuously appearing in the terminal:
TypeError: Cannot read properties of undefined (reading 'length')
    at Object.checkMaximumNumberEventsPerMessage (POS2.js:16745:30)

If we take a look at the state after this happens, we encounter a state that is semi-compressed, and this seems to be the thing that's generating that error. It is not very clear what is causing it, for now we know is not the service workers, as this also happens on locally node deployed pos2.

Check the attached screenshot and video for more details.
1. Go to pos2 in livebuilds: https://livebuilds.openbravo.com/retail_pos2_pgsql/web/pos/?terminal=VBS-2 [^]
2. Open developer tools in chrome, and go to tab "Application"
3. Click on the left, click on Storage, and then on the button "Clear site data"

Refresh the web, you should reproduce the problem. Check the attached gif for extra info.
No tags attached.
depends on backport 0050478RR22Q4.1 closed cberner Retail Modules State compression on occasions breaks the state on deployed pos2 
depends on backport 0050479RR22Q3.2 closed cberner Retail Modules State compression on occasions breaks the state on deployed pos2 
png errorCompression.png (112,986) 2022-09-22 16:21
https://issues.openbravo.com/file_download.php?file_id=17540&type=bug
png

png semiCompressedState.png (264,496) 2022-09-22 16:21
https://issues.openbravo.com/file_download.php?file_id=17541&type=bug
gif errorsCompression.gif (1,398,761) 2022-09-22 16:22
https://issues.openbravo.com/file_download.php?file_id=17542&type=bug
Issue History
2022-09-22 16:21cbernerNew Issue
2022-09-22 16:21cbernerAssigned To => Triage Platform Base
2022-09-22 16:21cbernerFile Added: errorCompression.png
2022-09-22 16:21cbernerTriggers an Emergency Pack => No
2022-09-22 16:21cbernerFile Added: semiCompressedState.png
2022-09-22 16:22cbernerFile Added: errorsCompression.gif
2022-10-03 16:14andre_montenegroNote Added: 0141581
2022-10-06 12:02cbernerNote Added: 0141722
2022-10-07 11:46hgbotNote Added: 0141849
2022-10-07 13:46cbernerAssigned ToTriage Platform Base => cberner
2022-10-07 13:46cbernerStatusnew => scheduled
2022-10-10 18:52hgbotResolutionopen => fixed
2022-10-10 18:52hgbotStatusscheduled => closed
2022-10-10 18:52hgbotFixed in Version => RR23Q1
2022-10-10 18:52hgbotNote Added: 0141933
2022-10-10 18:52hgbotNote Added: 0141934
2022-10-11 12:23cbernerStatusclosed => new
2022-10-11 12:23cbernerResolutionfixed => open
2022-10-11 12:23cbernerFixed in VersionRR23Q1 =>
2022-10-11 12:24cbernerStatusnew => scheduled
2022-10-11 12:25cbernerStatusscheduled => resolved
2022-10-11 12:25cbernerFixed in Version => 23Q1
2022-10-11 12:25cbernerResolutionopen => fixed
2022-10-11 12:25cbernerReview Assigned To => AugustoMauch
2022-10-11 12:25cbernerStatusresolved => closed

Notes
(0141581)
andre_montenegro   
2022-10-03 16:14   
This issue also affects Cypress tests when executing 2 different test which need to refresh page (not singleLogin related). So, for now and until the issue is fixed, cashup and login tests will be skipped: https://gitlab.com/openbravo/product/pmods/org.openbravo.pos2/-/merge_requests/1238 [^]
(0141722)
cberner   
2022-10-06 12:02   
Some extra research has been done for this issue. We know where it happens:
https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core/-/blob/master/web/org.openbravo.mobile.core/app/model/application-state/StatePersistence.js#L266 [^]

When cache is cleared through devtools and we're still in the login screen, it will persist the state but without updating the localstorage property "statePersistenceMethod", which results in the system thinking there's a state, but it is not compressed, when indeed it is compressed.

On refresh, it will break because it will assume a non-compressed state, while it is actually compressed. I'm still working on finding a proper solution for this.
(0141849)
hgbot   
2022-10-07 11:46   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core/-/merge_requests/419 [^]
(0141933)
hgbot   
2022-10-10 18:52   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core [^]
Changeset: d2cd412b1fcf55901e3f897bbe9f583170b29d01
Author: Cristian Berner <cristian.berner@openbravo.com>
Date: 10-10-2022 18:52:03
URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core/-/commit/d2cd412b1fcf55901e3f897bbe9f583170b29d01 [^]

Fixes ISSUE-50314: State persistence compression breaks in occasions on pos2

This was due to how the compressed state is saved in the localstorage.
If the localstorage is cleaned while in the application, being it in the
login screen or in another part of the application, that would result in
the state being persisted just after clearing localstorage.

After a refresh, this state saved in the localstorage would result in an
error, because we would try to compress the already compressed state
again, which is wrong. To fix this, we're checking if the property in
the state "isGlobalState" exists and is of boolean type, then the state
is not compressed. We can assume this, because the property is always
available as part of the main state and when compressed it is a string
instead of a boolean variable.

---
M web/org.openbravo.mobile.core/app/model/application-state/StatePersistence.js
---
(0141934)
hgbot   
2022-10-10 18:52   
Merge request merged: https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core/-/merge_requests/419 [^]