BioplatformsAustralia / bpaotu

OTU database access for the Australian Microbiome
GNU Affero General Public License v3.0
5 stars 1 forks source link

Random crash in marshallContextualFilters. race? #246

Closed hou098 closed 1 year ago

hou098 commented 1 year ago

Seems to only occur when switching to "search" tab from "map" tab

TypeError: dataDefinition is undefined
./src/pages/search_page/reducers/search.ts/marshallContextualFilters/filters<
src/pages/search_page/reducers/search.ts:23

  20 | const dataDefinition = filterDataDefinition(filter.name)
  21 | 
  22 | const values: any = {}
> 23 | switch (dataDefinition.type) { // FIXME can be undefined
     | ^  24 |   case 'string':
  25 |     values.contains = filter.value
  26 |     break

marshallContextualFilters
src/pages/search_page/reducers/search.ts:19

  16 | 
  17 | function marshallContextualFilters(filtersState, dataDefinitions) {
  18 |   const filterDataDefinition = name => find(dataDefinitions.filters, dd => dd.name === name)
> 19 |   const filters = map(reject(filtersState, filter => filter.name === ''), filter => {
  20 |     const dataDefinition = filterDataDefinition(filter.name)
  21 | 
  22 |     const values: any = {}

marshallContextual
src/pages/search_page/reducers/search.ts:55

  52 |   return {
  53 |     environment: selectedEnvironment.value === '' ? null : selectedEnvironment,
  54 |     mode: filtersMode,
> 55 |     filters: marshallContextualFilters(state.filters, contextualDataDefinitions)
  56 |   }
  57 | }
  58 | 

describeSearch
src/pages/search_page/reducers/search.ts:70

  67 |     amplicon_filter: selectedAmplicon,
  68 |     trait_filter: selectedTrait,
  69 |     taxonomy_filters: selectedTaxonomies,
> 70 |     contextual_filters: marshallContextual(stateFilters.contextual, contextualDataDefinitions)
  71 |   }
  72 | }
  73 | 

./src/pages/search_page/reducers/search.ts/search/<
src/pages/search_page/reducers/search.ts:79

  76 | 
  77 | dispatch(searchStarted())
  78 | 
> 79 | const filters = describeSearch(state)
     | ^  80 | 
  81 | const options = {
  82 |   ...state.searchPage.results,

componentDidMount
src/components/search_results_table.tsx:45

  42 | 
  43 | public componentDidMount() {
  44 |   if (isEmpty(this.props.results.data)) {
> 45 |     this.props.search()
     | ^  46 |   }
  47 | }
  48 | 

./src/index.tsx/<
src/index.tsx:21

  18 | 
  19 | axios.get(window.otu_search_config.base_url + '/private/api/v1/config').then(function(response) {
  20 |     window.otu_search_config = response.data;
> 21 |     ReactDOM.render(
  22 |     <Provider store={store}>
  23 |         <Router basename={window.otu_search_config.base_url}>
  24 |         <App />

promise callback*./src/index.tsx
src/index.tsx:19

  16 | 
  17 | export const store = createStore(reducers, composeEnhancers(applyMiddleware(thunk)))
  18 | 
> 19 | axios.get(window.otu_search_config.base_url + '/private/api/v1/config').then(function(response) {
  20 |     window.otu_search_config = response.data;
  21 |     ReactDOM.render(
  22 |     <Provider store={store}>

__webpack_require__
/home/hou098/bpaotu/frontend/webpack/bootstrap:785

  782 | };
  783 | 
  784 | // Execute the module function
> 785 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
      | ^  786 | 
  787 | // Flag the module as loaded
  788 | module.l = true;
hou098 commented 1 year ago

Might only occur when switching between https://github.com/BioplatformsAustralia/bpaotu/tree/metagenome-feature-WIP and https://github.com/BioplatformsAustralia/bpaotu/tree/master during development.

See https://github.com/BioplatformsAustralia/bpaotu/commit/dddf396935e20b04c34d313b2fce3a44a688b4d1#diff-b751e87d1c0782ff58430855c00c92b36a743b0489a9534eb5b9cff17ddda7e7L43

hou098 commented 1 year ago

To reproduce:

Does not affect dddf396935e20b04c34d313b2fce3a44a688b4d1 or later due to https://github.com/BioplatformsAustralia/bpaotu/commit/dddf396935e20b04c34d313b2fce3a44a688b4d1#diff-b751e87d1c0782ff58430855c00c92b36a743b0489a9534eb5b9cff17ddda7e7L43