refactor: remove unnecessary parameters and comments in QuickJS VM execution

This commit is contained in:
sanish-bruno
2026-01-29 14:19:37 +05:30
parent 5e03846da6
commit 63e5fbab36
2 changed files with 2 additions and 14 deletions

View File

@@ -158,8 +158,7 @@ class HooksRuntime {
const result = await executeQuickJsVmAsync({
script: hooksFile,
context: context,
collectionPath,
persistVm: true // Keep VM alive for hook handler calls
collectionPath
});
// Register VM cleanup with HookManager so it's disposed when HookManager.dispose() is called

View File

@@ -89,17 +89,6 @@ const executeQuickJsVm = ({ script: externalScript, context: externalContext, sc
}
};
/**
* Execute a script asynchronously in a QuickJS VM
* @param {Object} options - Execution options
* @param {string} options.script - The script to execute
* @param {Object} options.context - Context object with bru, req, res, etc.
* @param {string} options.collectionPath - Path to the collection
* @param {boolean} options.persistVm - If true, VM persists and cleanup function is returned.
* Used for hooks that need to be called later.
* If false (default), VM is disposed immediately.
* @returns {Promise<Object|undefined>} Returns { cleanup } if persistVm=true, undefined otherwise
*/
const executeQuickJsVmAsync = async ({ script: externalScript, context: externalContext, collectionPath }) => {
if (!externalScript?.length || typeof externalScript !== 'string') {
return externalScript;
@@ -107,7 +96,6 @@ const executeQuickJsVmAsync = async ({ script: externalScript, context: external
externalScript = externalScript?.trim();
try {
// Create new WASM module each time (no memoization)
const module = await newQuickJSWASMModule();
const vm = module.newContext();
@@ -193,6 +181,7 @@ const executeQuickJsVmAsync = async ({ script: externalScript, context: external
promiseHandle.dispose();
const resolvedHandle = vm.unwrapResult(resolvedResult);
resolvedHandle.dispose();
// vm.dispose();
return;
} catch (error) {
console.error('Error executing the script!', error);