Commit ee1ec67c authored by Tim Neutkens's avatar Tim Neutkens

Reapply "Another approach"

This reverts commit 0afed19c.
parent 0afed19c
...@@ -34,12 +34,6 @@ export declare class ExternalObject<T> { ...@@ -34,12 +34,6 @@ export declare class ExternalObject<T> {
[K: symbol]: T [K: symbol]: T
} }
} }
export interface TransformOutput {
code: string
map?: string
output?: string
diagnostics: Array<string>
}
export declare function mdxCompile( export declare function mdxCompile(
value: string, value: string,
option: Buffer, option: Buffer,
......
...@@ -236,7 +236,7 @@ describe('next.rs api writeToDisk multiple times', () => { ...@@ -236,7 +236,7 @@ describe('next.rs api writeToDisk multiple times', () => {
const route = entrypoints.routes.get('/app-nodejs') const route = entrypoints.routes.get('/app-nodejs')
if (route.type === 'app-page') { if (route.type === 'app-page') {
for (let i = 0; i < 100; i++) { for (let i = 0; i < Infinity; i++) {
console.log(i) console.log(i)
await route.pages[0].htmlEndpoint.writeToDisk() await route.pages[0].htmlEndpoint.writeToDisk()
} }
......
...@@ -2022,7 +2022,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -2022,7 +2022,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
}; };
let InProgressState::InProgress(box InProgressStateInner { let InProgressState::InProgress(box InProgressStateInner {
done_event, done_event,
once_task, once_task: _,
stale, stale,
session_dependent, session_dependent,
done: _, done: _,
...@@ -2138,15 +2138,6 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -2138,15 +2138,6 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
task.shrink_to_fit(CachedDataItemType::CollectiblesDependency); task.shrink_to_fit(CachedDataItemType::CollectiblesDependency);
drop(task); drop(task);
// ✅ ADD: Remove Once tasks from transient_tasks after completion
if once_task && !stale {
self.transient_tasks.remove(&task_id);
// CRITICAL: Return the task ID to the factory for reuse
unsafe {
self.transient_task_id_factory.reuse(task_id);
}
}
false false
} }
...@@ -2575,6 +2566,12 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -2575,6 +2566,12 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
let mut ctx = self.execute_context(turbo_tasks); let mut ctx = self.execute_context(turbo_tasks);
let mut task = ctx.task(task_id, TaskDataCategory::All); let mut task = ctx.task(task_id, TaskDataCategory::All);
// Check if this is a Once task by examining the root type
let is_once_task = get!(task, Activeness)
.map(|activeness| matches!(activeness.root_ty, Some(RootType::OnceTask)))
.unwrap_or(false);
let is_dirty = get!(task, Dirty).map_or(false, |dirty| dirty.get(self.session_id)); let is_dirty = get!(task, Dirty).map_or(false, |dirty| dirty.get(self.session_id));
let has_dirty_containers = get!(task, AggregatedDirtyContainerCount) let has_dirty_containers = get!(task, AggregatedDirtyContainerCount)
.map_or(false, |dirty_containers| { .map_or(false, |dirty_containers| {
...@@ -2591,6 +2588,22 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -2591,6 +2588,22 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
// we notify it anyway // we notify it anyway
activeness_state.all_clean_event.notify(usize::MAX); activeness_state.all_clean_event.notify(usize::MAX);
} }
// ✅ PROPER FIX: Once tasks should be completely cleaned up when disposed
if is_once_task {
// Drop the task and context to release locks before cleanup
drop(task);
drop(ctx);
// Remove from transient_tasks tracking
self.transient_tasks.remove(&task_id);
// Completely remove all storage data for this task
self.storage.remove_task(task_id);
// Return the task ID to the factory for reuse
unsafe {
self.transient_task_id_factory.reuse(task_id);
}
}
} }
#[cfg(feature = "verify_aggregation_graph")] #[cfg(feature = "verify_aggregation_graph")]
......
...@@ -812,6 +812,15 @@ impl Storage { ...@@ -812,6 +812,15 @@ impl Storage {
) )
} }
/// Completely removes a task from storage, including all its data and metadata.
/// This should only be called for tasks that are guaranteed to never be accessed again.
pub fn remove_task(&self, task_id: TaskId) {
// Remove from the main storage map
self.map.remove(&task_id);
// Remove from the modified tracking
self.modified.remove(&task_id);
}
pub fn drop_contents(&self) { pub fn drop_contents(&self) {
drop_contents(&self.map); drop_contents(&self.map);
drop_contents(&self.modified); drop_contents(&self.modified);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment