fix: enter V8 isolate/context scope before editor codegen compile - #221
Merged
Conversation
generate_scene_nodes_types and generate_resource_types compiled a V8 script with only a HandleScope entered, unlike the working generate_types path; on a cold/batch reimport this segfaulted inside v8::Script::Compile. Enter the v8::Isolate::Scope and v8::Context::Scope before compile_function at both sites.
Member
|
This is a definite, yes, from me because I have this EXACT same patch locally and I really should have pushed it already, but it's currently sitting atop a local branch with much more dubious commits below it in stack. This regressed in a01cc6d. |
Benjamin-Dobell
enabled auto-merge (rebase)
June 13, 2026 14:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the editor builds the TypeScript type definitions for your project, it runs a small piece of JavaScript through the V8 engine to compile it. Before V8 can compile anything, the code has to "enter" the right V8 isolate and context — basically telling V8 which JavaScript world to work in.
Two of these code paths forgot that step: the one that builds types for scene nodes (
generate_scene_nodes_types) and the one that builds types for resources (generate_resource_types). They entered only aHandleScope, not theIsolate::ScopeandContext::Scope. The third path that does the same kind of work (generate_types) enters all three and works fine.The result: on a cold start, or when you reimport a lot of files at once, the editor crashes (segfault) deep inside V8's compile step.
What this changes
Add the two missing scope guards (
v8::Isolate::Scopeandv8::Context::Scope) at both sites, in the same positions as the path that already works (generate_types): theIsolate::Scopealongside the existingHandleScope, and theContext::Scopebefore the compile call. No logic changes — it just adds two stack guards per site, using the same isolate and context the surrounding code already had.How to verify
Rebuild the engine and trigger a batch reimport (or a cold editor start that regenerates types) to confirm the crash is gone.
A changeset is included.