+2
-8
src/index.ts
+2
-8
src/index.ts
···
141
141
} catch (_error) {
142
142
// When we're unsuccessful we revert to the original `globalThis`
143
143
vmGlobals = trueGlobal;
144
+
} finally {
144
145
if (iframe) iframe.remove();
145
146
}
146
147
}
···
160
161
// We also reset all ignored keys explicitly
161
162
for (const key in ignore) safeGlobal[key] = undefined;
162
163
// Lastly, we also disallow certain property accesses on the safe global
163
-
safeGlobal = withProxy(safeGlobal!);
164
-
165
-
// We're now free to remove the iframe element, if we've used it
166
-
if (iframe) {
167
-
iframe.remove();
168
-
}
169
-
170
-
return safeGlobal;
164
+
return (safeGlobal = withProxy(safeGlobal!));
171
165
}
172
166
173
167
interface SafeFunction {