Skip to content

UI crashes due to missing deposit info #479

@Keith-CY

Description

@Keith-CY

Describe the bug
We've got a case that when user visit the Nervos DAO page, the window kept flickering. After checking the debug info we found the following error

[2025-08-12T05:24:21.629Z] [error] [
  "UI crash: Cannot read properties of undefined (reading 'timestamp')",
  {
    stack: "TypeError: Cannot read properties of undefined (reading 'timestamp')\n" +
      '    at file:///C:/Program Files/Neuron/resources/app.asar/dist/neuron-ui/index.js:146:86393\n' +
      '    at Array.sort (<anonymous>)\n' +
      '    at file:///C:/Program Files/Neuron/resources/app.asar/dist/neuron-ui/index.js:146:86360\n' +
      '    at Object.Kl [as useMemo] (file:///C:/Program Files/Neuron/resources/app.asar/dist/neuron-ui/index.js:38:23635)\n' +
      '    at react_production_min.useMemo (file:///C:/Program Files/Neuron/resources/app.asar/dist/neuron-ui/index.js:9:7306)\n' +
      '    at NervosDAO (file:///C:/Program Files/Neuron/resources/app.asar/dist/neuron-ui/index.js:146:86182)\n' +
      '    at Va (file:///C:/Program Files/Neuron/resources/app.asar/dist/neuron-ui/index.js:38:18836)\n' +
      '    at so (file:///C:/Program Files/Neuron/resources/app.asar/dist/neuron-ui/index.js:40:3497)\n' +
      '    at Oc (file:///C:/Program Files/Neuron/resources/app.asar/dist/neuron-ui/index.js:40:49321)\n' +
      '    at Lc (file:///C:/Program Files/Neuron/resources/app.asar/dist/neuron-ui/index.js:40:43713)',
    componentStack: 'N/A'
  }
]

It indicates that at https://github.com/nervosnetwork/neuron/blob/v0.202.1/packages/neuron-ui/src/components/NervosDAO/index.tsx#L157-L165

    if (tabIdx === '0') {
      filteredRecord.sort((r1, r2) =>
        isDescDirection
          ? +r2.depositInfo!.timestamp! - +r1.depositInfo!.timestamp!
          : +r1.depositInfo!.timestamp! - +r2.depositInfo!.timestamp!
      )
    } else if (tabIdx === '1') {
      filteredRecord.sort((r1, r2) => +r2.unlockInfo!.timestamp! - +r1.unlockInfo!.timestamp!)
    }

The depositInfo of r is undefined which is unexpected.

There are 2 issues

  1. depositInfo should not be undefined
  2. non-null assertion is abused here so the exception is not properly handled which makes the UI crashed.

Expected behavior

Every record should have deposit info

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions