diff --git a/core/ssb.js b/core/ssb.js index 219c91f3..3a4c5dd6 100644 --- a/core/ssb.js +++ b/core/ssb.js @@ -96,6 +96,9 @@ function tunnel_attendants(request) { function send_blobs_create_wants(connection) { connection.send_json({'name': ['blobs', 'createWants'], 'type': 'source', 'args': []}, function on_blob_create_wants(message) { + if (message.message?.name === 'Error') { + return; + } Object.keys(message.message).forEach(function(id) { if (message.message[id] < 0) { if (g_wants_requests[connection.id]) { @@ -234,6 +237,9 @@ ssb.addRpc(['tunnel', 'isRoom'], function(request) { }); function notify_attendant_changed(id, type) { + if (!id) { + print(`notify_attendant_changed called with id=${id}`); + } for (let r of Object.values(g_attendants)) { try { r.send_json({ @@ -241,8 +247,8 @@ function notify_attendant_changed(id, type) { id: id, }); } catch (e) { - print(`Removing ${r.connection.id} from g_attendants in ${type}.`, e); - delete g_attendants[r.connection.id]; + print(`Removing ${id} from g_attendants in ${type}.`, e); + delete g_attendants[id]; } } } diff --git a/src/ssb.js.c b/src/ssb.js.c index ce42cf1f..06eec295 100644 --- a/src/ssb.js.c +++ b/src/ssb.js.c @@ -750,29 +750,9 @@ void tf_ssb_run_file(JSContext* context, const char* file_name) fclose(file); JSValue result = JS_Eval(context, source, file_size, file_name, 0); - if (JS_IsError(context, result)) + if (tf_util_report_error(context, result)) { printf("Error running %s.\n", file_name); - const char* value = JS_ToCString(context, result); - printf("ERROR: %s\n", value); - JS_FreeCString(context, value); - JSValue stack = JS_GetPropertyStr(context, result, "stack"); - if (!JS_IsUndefined(stack)) - { - const char* stack_str = JS_ToCString(context, stack); - printf("%s\n", stack_str); - JS_FreeCString(context, stack_str); - } - JS_FreeValue(context, stack); - } - else if (JS_IsException(result)) - { - printf("Exception running %s.\n", file_name); - JSValue error = JS_GetException(context); - const char* value = JS_ToCString(context, error); - printf("Exception: %s\n", value); - JS_FreeCString(context, value); - JS_FreeValue(context, error); } JSRuntime* runtime = JS_GetRuntime(context);