From 5089894b188caecb3264b5c6c4da4ea1f97a8262 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 30 Jul 2021 07:56:22 +0200 Subject: [PATCH] fail fast if the delegate was collected prematurely (#56523) --- src/mono/wasm/runtime/binding_support.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mono/wasm/runtime/binding_support.js b/src/mono/wasm/runtime/binding_support.js index d9d02da..85b8944 100644 --- a/src/mono/wasm/runtime/binding_support.js +++ b/src/mono/wasm/runtime/binding_support.js @@ -892,6 +892,12 @@ var BindingSupportLib = { // It's possible the managed object corresponding to this JS object was collected, // in which case we need to make a new one. if (!result) { + + if (typeof js_obj.__mono_delegate_alive__ !== "undefined") { + console.log("The delegate target that is being invoked is no longer available. Please check if it has been prematurely GC'd."); + return null; + } + delete js_obj.__mono_gchandle__; delete js_obj.is_mono_bridged_obj; } -- 2.7.4