diff --git a/apps/oxlint/src/raw_fs.rs b/apps/oxlint/src/raw_fs.rs index f40893fde18c5..25fd4e4d0cf75 100644 --- a/apps/oxlint/src/raw_fs.rs +++ b/apps/oxlint/src/raw_fs.rs @@ -14,7 +14,7 @@ use oxc_linter::RuntimeFileSystem; /// Identical to `OsFileSystem`, except that `read_to_arena_str` reads the file's contents into /// start of the allocator, instead of the end. This conforms to what raw transfer needs. /// -/// Must only be used in conjunction with `AllocatorPool` with `fixed_size` feature enabled, +/// Must only be used in conjunction with `AllocatorPool` created with `new_fixed_size`, /// which wraps `Allocator`s with a custom `Drop` impl, which makes `read_to_arena_str` safe. /// /// This is a temporary solution. When we replace `bumpalo` with our own allocator, all strings diff --git a/crates/oxc_linter/Cargo.toml b/crates/oxc_linter/Cargo.toml index d8a17b711f98e..2760b4741bde3 100644 --- a/crates/oxc_linter/Cargo.toml +++ b/crates/oxc_linter/Cargo.toml @@ -17,7 +17,7 @@ description.workspace = true default = [] ruledocs = ["oxc_macros/ruledocs"] # Enables the `ruledocs` feature for conditional compilation language_server = ["oxc_data_structures/rope"] # For the Runtime to support needed information for the language server -oxlint2 = ["dep:oxc_ast_macros", "oxc_ast_visit/serialize", "tokio/rt-multi-thread"] +oxlint2 = ["dep:oxc_ast_macros", "oxc_allocator/fixed_size", "oxc_ast_visit/serialize", "tokio/rt-multi-thread"] disable_oxlint2 = [] force_test_reporter = [] diff --git a/crates/oxc_linter/src/service/runtime.rs b/crates/oxc_linter/src/service/runtime.rs index 7f1326485662f..66b455919f0b1 100644 --- a/crates/oxc_linter/src/service/runtime.rs +++ b/crates/oxc_linter/src/service/runtime.rs @@ -265,7 +265,21 @@ impl Runtime { let _ = rayon::ThreadPoolBuilder::new().build_global(); let thread_count = rayon::current_num_threads(); - let allocator_pool = AllocatorPool::new(thread_count); + + // If an external linter is used (JS plugins), we must use fixed-size allocators, + // for compatibility with raw transfer + let allocator_pool = if linter.has_external_linter() { + #[cfg(all(feature = "oxlint2", not(feature = "disable_oxlint2")))] + { + AllocatorPool::new_fixed_size(thread_count) + } + #[cfg(not(all(feature = "oxlint2", not(feature = "disable_oxlint2"))))] + { + panic!("`oxlint2` feature must be enabled when using external linters"); + } + } else { + AllocatorPool::new(thread_count) + }; let resolver = options.cross_module.then(|| { Self::get_resolver(options.tsconfig.or_else(|| Some(options.cwd.join("tsconfig.json"))))