From 7208d15dce552289e530ed470d66c05a65a7239a Mon Sep 17 00:00:00 2001 From: Michael Anthony Leon Date: Tue, 18 Oct 2022 17:18:16 -0700 Subject: [PATCH] Support Symbols & BigInts in the debugger 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 --- .../hermes/inspector/chrome/MessageConverters.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ReactCommon/hermes/inspector/chrome/MessageConverters.cpp b/ReactCommon/hermes/inspector/chrome/MessageConverters.cpp index 3ffc17d0b5aab7..7bf892d59f45eb 100644 --- a/ReactCommon/hermes/inspector/chrome/MessageConverters.cpp +++ b/ReactCommon/hermes/inspector/chrome/MessageConverters.cpp @@ -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);