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

Timeline error in epic "setIsIntervalData" #8346

Closed
1 task done
allyoucanmap opened this issue Jun 20, 2022 · 8 comments
Closed
1 task done

Timeline error in epic "setIsIntervalData" #8346

allyoucanmap opened this issue Jun 20, 2022 · 8 comments

Comments

@allyoucanmap
Copy link
Contributor

allyoucanmap commented Jun 20, 2022

Description

How to reproduce

Expected Result

We should fix the error and verify why is it not able to compute the result for the setIsIntervalData flow

Current Result

  • error in console
Error in epic "setIsIntervalData". Original error: TypeError: Cannot read properties of null (reading 'indexOf')
  • Not browser related
Browser info (use this site: https://www.whatsmybrowser.org/ for non expert users)
Browser Affected Version
Internet Explorer
Edge
Chrome
Firefox
Safari

Other useful information

map for testing
timeline-map.zip

@tdipisa
Copy link
Member

tdipisa commented Jun 23, 2022

@dsuren1 I need first of all an investigation to understand if this issue is a regression or not included after recent updates we provided for the timeline (eg. #7958).

@dsuren1
Copy link
Contributor

dsuren1 commented Jun 27, 2022

@tdipisa
This issue is a regression caused by this #8229 part of #7958 which introduced the new epics setIsIntervalData.

Problem is caused because the setIsIntervalData epics is executed even when no layer is selected which is required to generate arguments for getDomainValues service.
Hence an undefined url is used to fire domain service call resulting in null values of next and previous time value causing the exception.

Occurrences

  • On updating layer dimension data onMapConfigLoad
  • On traversing time when Snap to guide layer is disabled

Solution
Allow setIsIntervalData epics execution only layer is selected (timeline -> selectedLayer)

I will provide fix as part this issue itself.

@tdipisa
Copy link
Member

tdipisa commented Jun 27, 2022

@ale-cristofori do you see any cons in what proposed by @dsuren1 above?

@ale-cristofori
Copy link
Contributor

@tdipisa @dsuren1 no, but I would refactor the epic with two epics to keep concerns separated.

the one that listens for SELECT_LAYER will get the layerId from the action and filter out those layers that do not have an ID, like in this case the layer has not been loaded correctly.

the one that listens for SET_CURRENT_TIME will get the layerId from the state with selectedLayerSelector

.filter(({type, layerId}) => (type === SET_CURRENT_TIME || (type === SELECT_LAYER && layerId)))

@dsuren1
Copy link
Contributor

dsuren1 commented Jun 28, 2022

@ale-cristofori
From what I can infer, the problem is caused only by SET_CURRENT_TIME when no layer is selected and the value of selectedLayerSelector is undefined, i.e the layerId cannot be acquired from the selector.
So in domainArgs the value of selectedLayerUrl becomes undefined causing the error. Which can still happen with a separate epics.

How should we pick the layer to be used in this scenario, should we go with the first layer instead?

image

@ale-cristofori
Copy link
Contributor

@dsuren1 if the purpose is to avoid the request being fired with undefined layerId, shouldn't this cover both cases?

export const setIsIntervalData = (action$, { getState = () => { } } = {}) =>
    action$.ofType(SET_CURRENT_TIME, SELECT_LAYER)
        .filter(({layerId}) => layerId || selectedLayerSelector(getState()))
        .switchMap(({time: actionTime}) => getTimeIsInterval(actionTime, getState));

But maybe I am missing something. Let me know

@dsuren1
Copy link
Contributor

dsuren1 commented Jun 28, 2022

@dsuren1 if the purpose is to avoid the request being fired with undefined layerId, shouldn't this cover both cases?

export const setIsIntervalData = (action$, { getState = () => { } } = {}) =>
    action$.ofType(SET_CURRENT_TIME, SELECT_LAYER)
        .filter(({layerId}) => layerId || selectedLayerSelector(getState()))
        .switchMap(({time: actionTime}) => getTimeIsInterval(actionTime, getState));

But maybe I am missing something. Let me know

@ale-cristofori
That's exactly the solution I proposed in my comment above :)

Kindly let me know if I can proceed with it.

@ale-cristofori
Copy link
Contributor

@dsuren1, sorry I typed that response yesterday, end of working day and I re-thought about it this morning. You can proceed with it, I tested and it seems the specific error is gone
recording_1

dsuren1 added a commit to dsuren1/MapStore2 that referenced this issue Jun 28, 2022
@ElenaGallo ElenaGallo self-assigned this Jul 6, 2022
@offtherailz offtherailz added this to the v2022.02.00 milestone Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants