Dont cache code, may need to revert
This commit is contained in:
16
worker.ts
16
worker.ts
@@ -1,5 +1,5 @@
|
||||
// isolator/worker.ts
|
||||
const moduleCache = new Map();
|
||||
// No module cache to ensure fresh code for every execution.
|
||||
|
||||
const States = Object.freeze({
|
||||
SUCCESS: "SUCCESS",
|
||||
@@ -52,15 +52,11 @@ self.onmessage = async (e) => {
|
||||
status
|
||||
);
|
||||
|
||||
let userModule = moduleCache.get(code);
|
||||
if (!userModule) {
|
||||
// Use a data URL to import the user's code as an ES module.
|
||||
const dataUrl = `data:text/javascript;base64,${btoa(
|
||||
unescape(encodeURIComponent(code))
|
||||
)}`;
|
||||
userModule = await import(dataUrl);
|
||||
moduleCache.set(code, userModule);
|
||||
}
|
||||
// Use a data URL to import the user's code as a fresh ES module on every execution.
|
||||
const dataUrl = `data:text/javascript;base64,${btoa(
|
||||
unescape(encodeURIComponent(code))
|
||||
)}`;
|
||||
const userModule = await import(dataUrl);
|
||||
|
||||
if (typeof userModule.default !== "function") {
|
||||
throw new Error(
|
||||
|
||||
Reference in New Issue
Block a user