Skip to content

JavaScript error when assuming currentChapter() always returns something #18492

@Siderite

Description

@Siderite

Repro steps:

  1. Create a new study with a default chapter
  2. Delete the only chapter it has

Error:

/study/ydFN5F9w/CZQsfO8R - Uncaught TypeError: Cannot read properties of undefined (reading 'players') - (https://lichess1.org/assets/compiled/lib.M3FAU267.js:6:39929)
TypeError: Cannot read properties of undefined (reading 'players')
    at Object.Is (lib.M3FAU267.js:6:39929)
    at Qo (lib.M3FAU267.js:6:33712)
    at $h (lib.M3FAU267.js:6:64375)
    at lib.7SYXJDC4.js:1:2120
    at Xt.G [as redraw] (lib.7SYXJDC4.js:1:3497)
    at changeChapter (lib.M3FAU267.js:6:87780)
    at Xt.socketHandler (lib.M3FAU267.js:6:85541)
    at Object.receive [as socketReceive] (lib.M3FAU267.js:5:43297)
    at Object.receive (analyse.study.LTIO4XE2.js:1:1512)
    at handle (lib.SFPXEOLA.js:2:2286)

The line in question is this:

const players = study.currentChapter().players,

In this situation, currentChapter() doesn't return anything.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions