A way to limit non-heap allocations (i.e. V8 "Large Object Storage" / Deno.memoryUsage().external
) in Web Workers for untrusted code
#26202
Labels
runtime
Relates to code in the runtime crate
suggestion
suggestions for new features (yet to be agreed)
Context: I have a use case where I need to run some untrusted1 code in a Worker without it being able to crash the whole Deno process.
To briefly summarize:
create_params.heap_limits
andjs_runtime.add_near_heap_limit_callback
.WEB_WORKER_HEAP_LIMIT_BYTES
env variable): https://gist.github.com/josephrocca/cf66802299505c51933413521a16a8b5Deno.memoryUsage().external
will not exceed a threshold. LuckilyDeno.memoryUsage().external
does seem to be specific to the Web Worker that it's called from. But in general I'm not sure how full-proof this strategy is.So I'm wondering:
deno_core
orrusty_v8
feature which could allow limiting the Large Object Space size for a Web Worker?workerOptions.deno.memoryLimit.heap
andworkerOptions.deno.memoryLimit.external
, so that a custom build wouldn't be required?Related:
ResourceLimits
don't work fornode:worker_threads
#26156setInterval
needs to be implemented manually IIUC.[1] By "untrusted" I don't mean that I need to worry about Spectre-type security issues. I just need to prevent it from crashing the process due to memory usage issues.
The text was updated successfully, but these errors were encountered: