Domiii / Domiii/dbux

Fix: trackable data types stored into `DataNode.value` causing encoding errors

Open
#665 0 comments 0 reactions 1 assignee Claimed by @Domiii View on GitHub
bug priority small
Dominant language
JavaScript
Stars
171
Forks
13
PR merge metrics
No merged PRs in 30d

Description

## Notes:

* Problem: shelljs has a `ShellString` object data type that sets its prototype to `String`, causing `valueCollection` to miscategorize it.
* ShellString is defined [here](https://github.com/shelljs/shelljs/blob/124d3349af42cb794ae8f78fc9b0b538109f7ca7/src/common.js#L150).
* The encoder uses `Object.keys` to iterate over props
* The encoder has the following logic for objects:
```js
if (typeof object === "string") {
this.encodeString(object);
}
else {
this.encodeObject(object, depth);
}
```
* because that is different from how we detect things, `ShellString`s get classified as "non-trackable" and thus their value is stored as-is into `DataNode`, via `valueCollection.registerValueMaybe`.

## TODO

* [ ] fix our object detection mechanism, or simply add an extra serialization step before storing plain values on `DataNode`
* [ ] test w/ `require4.js`

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.