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
e35ab359
Unverified
Commit
e35ab359
authored
Feb 27, 2025
by
Niklas Mischkulnig
Committed by
GitHub
Feb 27, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turbopack: prevent panic in swc issue emitter (#76595)
parent
bf1dfbba
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
18 deletions
+46
-18
analyze.rs
turbopack/crates/turbopack-core/src/issue/analyze.rs
+2
-2
mod.rs
turbopack/crates/turbopack-core/src/issue/mod.rs
+1
-1
export.rs
.../crates/turbopack-ecmascript/src/references/esm/export.rs
+1
-1
mod.rs
turbopack/crates/turbopack-ecmascript/src/references/mod.rs
+1
-1
emitter.rs
turbopack/crates/turbopack-swc-utils/src/emitter.rs
+41
-13
No files found.
turbopack/crates/turbopack-core/src/issue/analyze.rs
View file @
e35ab359
...
...
@@ -23,7 +23,7 @@ pub struct AnalyzeIssue {
impl
AnalyzeIssue
{
#[turbo_tasks
::
function]
pub
fn
new
(
severity
:
ResolvedVc
<
IssueSeverity
>
,
severity
:
IssueSeverity
,
source_ident
:
ResolvedVc
<
AssetIdent
>
,
title
:
ResolvedVc
<
RcStr
>
,
message
:
ResolvedVc
<
StyledString
>
,
...
...
@@ -31,7 +31,7 @@ impl AnalyzeIssue {
source
:
Option
<
IssueSource
>
,
)
->
Vc
<
Self
>
{
Self
{
severity
,
severity
:
severity
.resolved_cell
()
,
source_ident
,
title
,
message
,
...
...
turbopack/crates/turbopack-core/src/issue/mod.rs
View file @
e35ab359
...
...
@@ -30,7 +30,7 @@ use crate::{
};
#[turbo_tasks
::
value(shared)]
#[derive(PartialOrd,
Ord,
Copy,
Clone,
Hash,
Debug,
DeterministicHash)]
#[derive(PartialOrd,
Ord,
Copy,
Clone,
Hash,
Debug,
DeterministicHash
,
TaskInput
)]
#[serde(rename_all
=
"camelCase"
)]
pub
enum
IssueSeverity
{
Bug
,
...
...
turbopack/crates/turbopack-ecmascript/src/references/esm/export.rs
View file @
e35ab359
...
...
@@ -413,7 +413,7 @@ pub async fn expand_star_exports(
async
fn
emit_star_exports_issue
(
source_ident
:
Vc
<
AssetIdent
>
,
message
:
RcStr
)
->
Result
<
()
>
{
AnalyzeIssue
::
new
(
IssueSeverity
::
Warning
.cell
()
,
IssueSeverity
::
Warning
,
source_ident
,
Vc
::
cell
(
"unexpected export *"
.into
()),
StyledString
::
Text
(
message
)
.cell
(),
...
...
turbopack/crates/turbopack-ecmascript/src/references/mod.rs
View file @
e35ab359
...
...
@@ -939,7 +939,7 @@ pub(crate) async fn analyse_ecmascript_module_internal(
analysis
.set_async_module
(
async_module
);
}
else
if
let
Some
(
span
)
=
top_level_await_span
{
AnalyzeIssue
::
new
(
IssueSeverity
::
Error
.cell
()
,
IssueSeverity
::
Error
,
source
.ident
(),
Vc
::
cell
(
"unexpected top level await"
.into
()),
StyledString
::
Text
(
"top level await is only supported in ESM modules."
.into
())
...
...
turbopack/crates/turbopack-swc-utils/src/emitter.rs
View file @
e35ab359
...
...
@@ -27,19 +27,46 @@ impl IssueCollector {
};
for
issue
in
issues
{
issue
.to_resolved
()
.await
?
.emit
();
AnalyzeIssue
::
new
(
issue
.severity
,
issue
.source
.ident
(),
Vc
::
cell
(
issue
.title
),
issue
.message
.cell
(),
issue
.code
,
issue
.issue_source
,
)
.to_resolved
()
.await
?
.emit
();
}
Ok
(())
}
pub
fn
last_emitted_issue
(
&
self
)
->
Option
<
Vc
<
AnalyzeIssue
>>
{
let
inner
=
self
.inner
.lock
();
inner
.emitted_issues
.last
()
.copied
()
inner
.emitted_issues
.last
()
.map
(|
issue
|
{
AnalyzeIssue
::
new
(
issue
.severity
,
issue
.source
.ident
(),
Vc
::
cell
(
issue
.title
.clone
()),
issue
.message
.clone
()
.cell
(),
issue
.code
.clone
(),
issue
.issue_source
.clone
(),
)
})
}
}
struct
IssueCollectorInner
{
emitted_issues
:
Vec
<
Vc
<
AnalyzeIssue
>>
,
emitted_issues
:
Vec
<
PlainAnalyzeIssue
>
,
}
struct
PlainAnalyzeIssue
{
severity
:
IssueSeverity
,
source
:
ResolvedVc
<
Box
<
dyn
Source
>>
,
title
:
RcStr
,
message
:
StyledString
,
code
:
Option
<
RcStr
>
,
issue_source
:
Option
<
IssueSource
>
,
}
pub
struct
IssueEmitter
{
...
...
@@ -88,7 +115,7 @@ impl Emitter for IssueEmitter {
.as_ref
()
.is_some_and
(|
d
|
matches!
(
d
,
DiagnosticId
::
Lint
(
_
)));
let
severity
=
(
if
is_lint
{
let
severity
=
if
is_lint
{
IssueSeverity
::
Suggestion
}
else
{
match
level
{
...
...
@@ -101,8 +128,7 @@ impl Emitter for IssueEmitter {
Level
::
Cancelled
=>
IssueSeverity
::
Error
,
Level
::
FailureNote
=>
IssueSeverity
::
Note
,
}
})
.resolved_cell
();
};
let
title
;
if
let
Some
(
t
)
=
self
.title
.as_ref
()
{
...
...
@@ -118,14 +144,16 @@ impl Emitter for IssueEmitter {
});
// TODO add other primary and secondary spans with labels as sub_issues
let
issue
=
AnalyzeIssue
::
new
(
*
severity
,
self
.source
.ident
(),
Vc
::
cell
(
title
),
StyledString
::
Text
(
message
.into
())
.cell
(),
// This can be invoked by swc on different threads, so we cannot call any turbo-tasks or
// create cells here.
let
issue
=
PlainAnalyzeIssue
{
severity
,
source
:
self
.source
,
title
,
message
:
StyledString
::
Text
(
message
.into
()),
code
,
source
,
)
;
issue_source
:
source
,
}
;
let
mut
inner
=
self
.inner
.lock
();
inner
.emitted_issues
.push
(
issue
);
...
...
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