Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
b8a14cd8
Unverified
Commit
b8a14cd8
authored
Oct 31, 2025
by
Tobias Koppers
Committed by
GitHub
Oct 31, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turbopack: add track_caller to improve panics (#85565)
### What? Helps finding Item does not exist or access type errors
parent
3b0af3ce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
mod.rs
...k/crates/turbo-tasks-backend/src/backend/operation/mod.rs
+11
-0
No files found.
turbopack/crates/turbo-tasks-backend/src/backend/operation/mod.rs
View file @
b8a14cd8
...
@@ -382,6 +382,7 @@ impl<B: BackingStorage> TaskGuardImpl<'_, B> {
...
@@ -382,6 +382,7 @@ impl<B: BackingStorage> TaskGuardImpl<'_, B> {
/// Verify that the task guard restored the correct category
/// Verify that the task guard restored the correct category
/// before accessing the data.
/// before accessing the data.
#[inline]
#[inline]
#[track_caller]
fn
check_access
(
&
self
,
category
:
TaskDataCategory
)
{
fn
check_access
(
&
self
,
category
:
TaskDataCategory
)
{
{
{
match
category
{
match
category
{
...
@@ -434,6 +435,7 @@ impl<B: BackingStorage> TaskGuard for TaskGuardImpl<'_, B> {
...
@@ -434,6 +435,7 @@ impl<B: BackingStorage> TaskGuard for TaskGuardImpl<'_, B> {
self
.task_id
self
.task_id
}
}
#[track_caller]
fn
add
(
&
mut
self
,
item
:
CachedDataItem
)
->
bool
{
fn
add
(
&
mut
self
,
item
:
CachedDataItem
)
->
bool
{
let
category
=
item
.category
();
let
category
=
item
.category
();
self
.check_access
(
category
);
self
.check_access
(
category
);
...
@@ -446,12 +448,14 @@ impl<B: BackingStorage> TaskGuard for TaskGuardImpl<'_, B> {
...
@@ -446,12 +448,14 @@ impl<B: BackingStorage> TaskGuard for TaskGuardImpl<'_, B> {
self
.task
.add
(
item
)
self
.task
.add
(
item
)
}
}
#[track_caller]
fn
add_new
(
&
mut
self
,
item
:
CachedDataItem
)
{
fn
add_new
(
&
mut
self
,
item
:
CachedDataItem
)
{
self
.check_access
(
item
.category
());
self
.check_access
(
item
.category
());
let
added
=
self
.add
(
item
);
let
added
=
self
.add
(
item
);
assert
!
(
added
,
"Item already exists"
);
assert
!
(
added
,
"Item already exists"
);
}
}
#[track_caller]
fn
insert
(
&
mut
self
,
item
:
CachedDataItem
)
->
Option
<
CachedDataItemValue
>
{
fn
insert
(
&
mut
self
,
item
:
CachedDataItem
)
->
Option
<
CachedDataItemValue
>
{
let
category
=
item
.category
();
let
category
=
item
.category
();
self
.check_access
(
category
);
self
.check_access
(
category
);
...
@@ -461,6 +465,7 @@ impl<B: BackingStorage> TaskGuard for TaskGuardImpl<'_, B> {
...
@@ -461,6 +465,7 @@ impl<B: BackingStorage> TaskGuard for TaskGuardImpl<'_, B> {
self
.task
.insert
(
item
)
self
.task
.insert
(
item
)
}
}
#[track_caller]
fn
update
(
fn
update
(
&
mut
self
,
&
mut
self
,
key
:
CachedDataItemKey
,
key
:
CachedDataItemKey
,
...
@@ -474,6 +479,7 @@ impl<B: BackingStorage> TaskGuard for TaskGuardImpl<'_, B> {
...
@@ -474,6 +479,7 @@ impl<B: BackingStorage> TaskGuard for TaskGuardImpl<'_, B> {
self
.task
.update
(
key
,
update
);
self
.task
.update
(
key
,
update
);
}
}
#[track_caller]
fn
remove
(
&
mut
self
,
key
:
&
CachedDataItemKey
)
->
Option
<
CachedDataItemValue
>
{
fn
remove
(
&
mut
self
,
key
:
&
CachedDataItemKey
)
->
Option
<
CachedDataItemValue
>
{
let
category
=
key
.category
();
let
category
=
key
.category
();
self
.check_access
(
category
);
self
.check_access
(
category
);
...
@@ -488,6 +494,7 @@ impl<B: BackingStorage> TaskGuard for TaskGuardImpl<'_, B> {
...
@@ -488,6 +494,7 @@ impl<B: BackingStorage> TaskGuard for TaskGuardImpl<'_, B> {
self
.task
.get
(
key
)
self
.task
.get
(
key
)
}
}
#[track_caller]
fn
get_mut
(
&
mut
self
,
key
:
&
CachedDataItemKey
)
->
Option
<
CachedDataItemValueRefMut
<
'_
>>
{
fn
get_mut
(
&
mut
self
,
key
:
&
CachedDataItemKey
)
->
Option
<
CachedDataItemValueRefMut
<
'_
>>
{
let
category
=
key
.category
();
let
category
=
key
.category
();
self
.check_access
(
category
);
self
.check_access
(
category
);
...
@@ -497,6 +504,7 @@ impl<B: BackingStorage> TaskGuard for TaskGuardImpl<'_, B> {
...
@@ -497,6 +504,7 @@ impl<B: BackingStorage> TaskGuard for TaskGuardImpl<'_, B> {
self
.task
.get_mut
(
key
)
self
.task
.get_mut
(
key
)
}
}
#[track_caller]
fn
get_mut_or_insert_with
(
fn
get_mut_or_insert_with
(
&
mut
self
,
&
mut
self
,
key
:
CachedDataItemKey
,
key
:
CachedDataItemKey
,
...
@@ -510,11 +518,13 @@ impl<B: BackingStorage> TaskGuard for TaskGuardImpl<'_, B> {
...
@@ -510,11 +518,13 @@ impl<B: BackingStorage> TaskGuard for TaskGuardImpl<'_, B> {
self
.task
.get_mut_or_insert_with
(
key
,
insert
)
self
.task
.get_mut_or_insert_with
(
key
,
insert
)
}
}
#[track_caller]
fn
has_key
(
&
self
,
key
:
&
CachedDataItemKey
)
->
bool
{
fn
has_key
(
&
self
,
key
:
&
CachedDataItemKey
)
->
bool
{
self
.check_access
(
key
.category
());
self
.check_access
(
key
.category
());
self
.task
.contains_key
(
key
)
self
.task
.contains_key
(
key
)
}
}
#[track_caller]
fn
count
(
&
self
,
ty
:
CachedDataItemType
)
->
usize
{
fn
count
(
&
self
,
ty
:
CachedDataItemType
)
->
usize
{
self
.check_access
(
ty
.category
());
self
.check_access
(
ty
.category
());
self
.task
.count
(
ty
)
self
.task
.count
(
ty
)
...
@@ -532,6 +542,7 @@ impl<B: BackingStorage> TaskGuard for TaskGuardImpl<'_, B> {
...
@@ -532,6 +542,7 @@ impl<B: BackingStorage> TaskGuard for TaskGuardImpl<'_, B> {
self
.task
.shrink_to_fit
(
ty
)
self
.task
.shrink_to_fit
(
ty
)
}
}
#[track_caller]
fn
extract_if
<
'l
,
F
>
(
fn
extract_if
<
'l
,
F
>
(
&
'l
mut
self
,
&
'l
mut
self
,
ty
:
CachedDataItemType
,
ty
:
CachedDataItemType
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment