feat: warn when crash key name is longer than 39 bytes (#30742)
Signed-off-by: Darshan Sen <darshan.sen@postman.com>
This commit is contained in:
parent
55c57808fb
commit
90a3e7f927
1 changed files with 12 additions and 2 deletions
|
@ -17,7 +17,9 @@
|
||||||
#include "electron/buildflags/buildflags.h"
|
#include "electron/buildflags/buildflags.h"
|
||||||
#include "electron/fuses.h"
|
#include "electron/fuses.h"
|
||||||
#include "shell/common/electron_constants.h"
|
#include "shell/common/electron_constants.h"
|
||||||
|
#include "shell/common/node_includes.h"
|
||||||
#include "shell/common/options_switches.h"
|
#include "shell/common/options_switches.h"
|
||||||
|
#include "shell/common/process_util.h"
|
||||||
#include "third_party/crashpad/crashpad/client/annotation.h"
|
#include "third_party/crashpad/crashpad/client/annotation.h"
|
||||||
|
|
||||||
#include "gin/wrappable.h"
|
#include "gin/wrappable.h"
|
||||||
|
@ -93,9 +95,17 @@ static_assert(kMaxCrashKeyNameLength <= crashpad::Annotation::kNameMaxLength,
|
||||||
void SetCrashKey(const std::string& key, const std::string& value) {
|
void SetCrashKey(const std::string& key, const std::string& value) {
|
||||||
// Chrome DCHECK()s if we try to set an annotation with a name longer than
|
// Chrome DCHECK()s if we try to set an annotation with a name longer than
|
||||||
// the max.
|
// the max.
|
||||||
// TODO(nornagon): warn the developer (via console.warn) when this happens.
|
if (key.size() >= kMaxCrashKeyNameLength) {
|
||||||
if (key.size() >= kMaxCrashKeyNameLength)
|
node::Environment* env =
|
||||||
|
node::Environment::GetCurrent(JavascriptEnvironment::GetIsolate());
|
||||||
|
EmitWarning(env,
|
||||||
|
"The crash key name, \"" + key + "\", is longer than " +
|
||||||
|
std::to_string(kMaxCrashKeyNameLength) +
|
||||||
|
" bytes, ignoring it.",
|
||||||
|
"electron");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto& crash_key_names = GetExtraCrashKeyNames();
|
auto& crash_key_names = GetExtraCrashKeyNames();
|
||||||
|
|
||||||
auto iter = std::find(crash_key_names.begin(), crash_key_names.end(), key);
|
auto iter = std::find(crash_key_names.begin(), crash_key_names.end(), key);
|
||||||
|
|
Loading…
Reference in a new issue