···141141 } catch (_error) {
142142 // When we're unsuccessful we revert to the original `globalThis`
143143 vmGlobals = trueGlobal;
144144+ } finally {
144145 if (iframe) iframe.remove();
145146 }
146147 }
···160161 // We also reset all ignored keys explicitly
161162 for (const key in ignore) safeGlobal[key] = undefined;
162163 // Lastly, we also disallow certain property accesses on the safe global
163163- safeGlobal = withProxy(safeGlobal!);
164164-165165- // We're now free to remove the iframe element, if we've used it
166166- if (iframe) {
167167- iframe.remove();
168168- }
169169-170170- return safeGlobal;
164164+ return (safeGlobal = withProxy(safeGlobal!));
171165}
172166173167interface SafeFunction {