josdejong / josdejong/jsoneditor

"Cannot read properties of null (reading 'getInternalPath')"

Open
#1,498 4 comments 0 reactions 0 assignees View on GitHub
bug help wanted
Dominant language
JavaScript
Stars
12.3k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

I'm sporadically getting the following error when I change object keys (not values):

```
TypeError: Cannot read properties of null (reading 'getInternalPath')
S.value
https://76uwry.csb.app/node_modules/jsoneditor/dist/jsoneditor.min.js:33:36942
eval
https://76uwry.csb.app/node_modules/jsoneditor/dist/jsoneditor.min.js:35:2194
```

See https://codesandbox.io/s/jsoneditor-debounced-error-76uwry for an example: Try changing `hello`. (This calls `setValue` extremely fast to demonstrate the problem.)

I believe that the problem is caused by a race condition: Edits are propagated with a 150ms delay (due to the use of `debounce`), so, if the editor receives a new value, the old value has been removed and no longer has the fields that the event handler expects it to have.

https://github.com/josdejong/jsoneditor/blob/v9.9.2/src/js/Node.js#L1649

I'm not sure if the correct fix is to cancel debounced events when a node is removed (e.g., Lodash's debounce has a `cancel` function; a similar idea could be added here) or make the events check for, e.g., `this.parent == null`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.