Skip to content

[TS] Implement near-heap-limit termination#4777

Merged
coolreader18 merged 5 commits intomasterfrom
noa/v8-heap-limit-cb
Apr 22, 2026
Merged

[TS] Implement near-heap-limit termination#4777
coolreader18 merged 5 commits intomasterfrom
noa/v8-heap-limit-cb

Conversation

@coolreader18
Copy link
Copy Markdown
Collaborator

@coolreader18 coolreader18 commented Apr 10, 2026

Description of Changes

Uses Isolate::add_near_heap_limit_callback to prevent unbounded heap growth. Upon nearing the heap limit, we will now:

  1. Call Isolate::terminate_execution.
  2. Request that v8 double the heap limit.

Then, upon finishing a function call, we lower the heap limit back down.

This should hopefully fix the issue where v8 hits the heap limit and crashes the whole process.

Also improves the way termination requests are checked for and processed.

Expected complexity level and risk

2

Testing

  • Manual testing with memory-leaky modules

Comment thread crates/core/src/host/v8/mod.rs Outdated
Comment thread crates/core/src/host/v8/mod.rs Outdated
Comment thread crates/core/src/host/v8/mod.rs Outdated
Comment thread crates/core/src/host/v8/mod.rs
@coolreader18 coolreader18 added this pull request to the merge queue Apr 22, 2026
Merged via the queue into master with commit f896974 Apr 22, 2026
32 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants