Skip to content

Commit

Permalink
Support Symbols & BigInts in the debugger
Browse files Browse the repository at this point in the history
Summary:
Add full functionality for `Symbol`s and `BigInt`s in the debugger. Note- using the [protocol monitor](https://umaar.com/dev-tips/166-protocol-monitor/) was the most reliable way of figuring out which fields exactly need to be set for these types to play nicely in DevTools. I brought up the monitor and then used the regular, standard chrome console with the functionality I wanted:

- Evaluating `Symbol` and `BigInt` literals, like `Symbol.for("a")` and `1n`
- Right-click save the resulting expressions

From there, I inspected the CDP messages being sent. Then I was able to fill in the correct fields from there, and be confident that those were correct, given that I was copying the exact behavior of Chrome itself.

Changelog:
[General][Fixed] Support properly sending BigInts and Symbols over the Chrome DevTools Protocol.

Reviewed By: neildhar, jpporto

Differential Revision: D40442228

fbshipit-source-id: 98a514edbeb35fcbd427a25475f435e22956f2db
  • Loading branch information
Michael Anthony Leon authored and facebook-github-bot committed Oct 19, 2022
1 parent afb124d commit 7208d15
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ReactCommon/hermes/inspector/chrome/MessageConverters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@ m::runtime::RemoteObject m::runtime::makeRemoteObject(
} else if (value.isString()) {
result.type = "string";
result.value = value.getString(runtime).utf8(runtime);
} else if (value.isSymbol()) {
result.type = "symbol";
auto sym = value.getSymbol(runtime);
result.description = sym.toString(runtime);
result.objectId =
objTable.addValue(jsi::Value(std::move(sym)), objectGroup);
} else if (value.isBigInt()) {
auto strRepresentation =
value.getBigInt(runtime).toString(runtime).utf8(runtime) + 'n';
result.description = result.unserializableValue = strRepresentation;
} else if (value.isObject()) {
jsi::Object obj = value.getObject(runtime);

Expand Down

0 comments on commit 7208d15

Please sign in to comment.