not transfer data to worker for safety

This commit is contained in:
fyears 2024-09-01 17:26:32 +08:00
parent ac9c2a9248
commit 74e5231861
2 changed files with 7 additions and 5 deletions

View File

@ -202,7 +202,7 @@ export class CipherRclone {
}, },
[ [
channel.port1, channel.port1,
// input // the array buffer might be re-used later, so we CANNOT transform here // input // the array buffer might be re-used later, so we CANNOT transfer here
] ]
); );
}); });
@ -247,8 +247,10 @@ export class CipherRclone {
action: "decryptContent", action: "decryptContent",
inputContent: input, inputContent: input,
}, },
// the decrypted result is not used later in worker, so it's save to transfer [
[channel.port1, input] channel.port1,
input, // not transfer for safety
]
); );
}); });
} }

View File

@ -141,7 +141,7 @@ ctx.addEventListener("message", async (event: any) => {
status: "ok", status: "ok",
outputContent: outputContent, outputContent: outputContent,
}, },
[outputContent] [outputContent] // on worker side, we don't reuse anything so it's safe to transfer
); );
} catch (error) { } catch (error) {
console.error(error); console.error(error);
@ -166,7 +166,7 @@ ctx.addEventListener("message", async (event: any) => {
status: "ok", status: "ok",
outputContent: outputContent, outputContent: outputContent,
}, },
[outputContent] [outputContent] // on worker side, we don't reuse anything so it's safe to transfer
); );
} catch (error) { } catch (error) {
console.error(error); console.error(error);