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> {
[K: symbol]: T
}
}
export interface TransformOutput {
code: string
map?: string
output?: string
diagnostics: Array<string>
}
export declare function mdxCompile(
value: string,
option: Buffer,
......
......@@ -236,7 +236,7 @@ describe('next.rs api writeToDisk multiple times', () => {
const route = entrypoints.routes.get('/app-nodejs')
if (route.type === 'app-page') {
for (let i = 0; i < 100; i++) {
for (let i = 0; i < Infinity; i++) {
console.log(i)
await route.pages[0].htmlEndpoint.writeToDisk()
}
......
......@@ -2022,7 +2022,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
};
let InProgressState::InProgress(box InProgressStateInner {
done_event,
once_task,
once_task: _,
stale,
session_dependent,
done: _,
......@@ -2138,15 +2138,6 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
task.shrink_to_fit(CachedDataItemType::CollectiblesDependency);
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
}
......@@ -2575,6 +2566,12 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
let mut ctx = self.execute_context(turbo_tasks);
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 has_dirty_containers = get!(task, AggregatedDirtyContainerCount)
.map_or(false, |dirty_containers| {
......@@ -2591,6 +2588,22 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
// we notify it anyway
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")]
......
......@@ -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) {
drop_contents(&self.map);
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