summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Chimento <philip.chimento@gmail.com>2023-03-04 19:18:08 -0800
committerPhilip Chimento <philip.chimento@gmail.com>2023-03-04 23:40:33 -0800
commit9f119427e50557ba000c68c246303edbe3a3507e (patch)
tree9596ffcac374eb4798bf2b8e43cc68e917fb729e
parent73d6434471f35439b3fcb4e5718d7d7c3b692311 (diff)
downloadgjs-9f119427e50557ba000c68c246303edbe3a3507e.tar.gz
context: Instrument module evaluation promises with debug logs
-rw-r--r--gjs/context.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/gjs/context.cpp b/gjs/context.cpp
index be9049e6..c4abbbf9 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -531,6 +531,12 @@ static bool on_context_module_rejected_log_exception(JSContext* cx,
unsigned argc,
JS::Value* vp) {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
+
+ JSString* id =
+ JS_GetFunctionDisplayId(JS_GetObjectFunction(&args.callee()));
+ gjs_debug(GJS_DEBUG_IMPORTER, "Module evaluation promise rejected: %s",
+ gjs_debug_string(id).c_str());
+
JS::HandleValue error = args.get(0);
GjsContextPrivate* gjs_cx = GjsContextPrivate::from_cx(cx);
@@ -547,6 +553,12 @@ static bool on_context_module_rejected_log_exception(JSContext* cx,
static bool on_context_module_resolved(JSContext* cx, unsigned argc,
JS::Value* vp) {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
+
+ JSString* id =
+ JS_GetFunctionDisplayId(JS_GetObjectFunction(&args.callee()));
+ gjs_debug(GJS_DEBUG_IMPORTER, "Module evaluation promise resolved: %s",
+ gjs_debug_string(id).c_str());
+
args.rval().setUndefined();
GjsContextPrivate::from_cx(cx)->main_loop_release();
@@ -606,6 +618,12 @@ static void load_context_module(JSContext* cx, const char* uri,
[](JSContext* cx, unsigned argc, JS::Value* vp) {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
+ JSString* id =
+ JS_GetFunctionDisplayId(JS_GetObjectFunction(&args.callee()));
+ gjs_debug(GJS_DEBUG_IMPORTER,
+ "Module evaluation promise rejected: %s",
+ gjs_debug_string(id).c_str());
+
JS::HandleValue error = args.get(0);
// Abort because this module is required.
gjs_log_exception_full(cx, error, nullptr, G_LOG_LEVEL_ERROR);