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
874d9211
Commit
874d9211
authored
Jan 09, 2026
by
Tim Neutkens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use console.trace
parent
4e97364d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
11 deletions
+10
-11
console-dim.external.test.ts
.../node-environment-extensions/console-dim.external.test.ts
+3
-3
console-dim.external.tsx
...rver/node-environment-extensions/console-dim.external.tsx
+7
-8
No files found.
packages/next/src/server/node-environment-extensions/console-dim.external.test.ts
View file @
874d9211
...
@@ -361,12 +361,12 @@ describe('console-exit patches', () => {
...
@@ -361,12 +361,12 @@ describe('console-exit patches', () => {
async
function
testForWorker
()
{
async
function
testForWorker
()
{
let
capturedOutput
=
''
let
capturedOutput
=
''
// Replace console.
log to capture the trace output (console.trace uses console.log
internally after our patch)
// Replace console.
error to capture the trace output (console.trace uses console.error
internally after our patch)
console
.
log
=
function
(...
args
)
{
console
.
error
=
function
(...
args
)
{
capturedOutput
=
args
.
join
(
' '
)
capturedOutput
=
args
.
join
(
' '
)
reportResult
({
reportResult
({
type
:
'console-call'
,
type
:
'console-call'
,
method
:
'
log
'
,
method
:
'
error
'
,
input
:
capturedOutput
,
input
:
capturedOutput
,
})
})
}
}
...
...
packages/next/src/server/node-environment-extensions/console-dim.external.tsx
View file @
874d9211
...
@@ -204,7 +204,7 @@ function patchConsoleMethod(methodName: InterceptableConsoleMethod): void {
...
@@ -204,7 +204,7 @@ function patchConsoleMethod(methodName: InterceptableConsoleMethod): void {
const
consoleStore
=
consoleAsyncStorage
.
getStore
()
const
consoleStore
=
consoleAsyncStorage
.
getStore
()
// Special handling for console.trace: capture the stack trace early
// Special handling for console.trace: capture the stack trace early
// before the wrapper chain pollutes it, then use console.
log
to output
// before the wrapper chain pollutes it, then use console.
error
to output
let
traceStack
:
string
|
undefined
let
traceStack
:
string
|
undefined
if
(
methodName
===
'trace'
)
{
if
(
methodName
===
'trace'
)
{
traceStack
=
getCleanStackTrace
()
traceStack
=
getCleanStackTrace
()
...
@@ -329,10 +329,9 @@ function applyMethod<F extends (this: Console, ...args: any[]) => any>(
...
@@ -329,10 +329,9 @@ function applyMethod<F extends (this: Console, ...args: any[]) => any>(
traceStack
?:
string
traceStack
?:
string
):
ReturnType
<
F
>
{
):
ReturnType
<
F
>
{
if
(
methodName
===
'trace'
&&
traceStack
!==
undefined
)
{
if
(
methodName
===
'trace'
&&
traceStack
!==
undefined
)
{
// For console.trace, output the label + clean stack using console.log
// For console.trace, output the label + clean stack using console.error (stderr)
// This goes through the wrapper chain for proper file logging
const
label
=
args
.
length
>
0
?
`Trace:
${
args
.
join
(
' '
)}
`
:
'Trace'
const
label
=
args
.
length
>
0
?
`Trace:
${
args
.
join
(
' '
)}
`
:
'Trace'
return
console
.
log
(
`
${
label
}
\n
${
traceStack
}
`
)
as
ReturnType
<
F
>
return
console
.
error
(
`
${
label
}
\n
${
traceStack
}
`
)
as
ReturnType
<
F
>
}
}
return
method
.
apply
(
this
,
args
)
return
method
.
apply
(
this
,
args
)
}
}
...
@@ -349,13 +348,13 @@ function applyWithDimming<F extends (this: Console, ...args: any[]) => any>(
...
@@ -349,13 +348,13 @@ function applyWithDimming<F extends (this: Console, ...args: any[]) => any>(
if
(
methodName
===
'trace'
&&
traceStack
!==
undefined
)
{
if
(
methodName
===
'trace'
&&
traceStack
!==
undefined
)
{
const
label
=
args
.
length
>
0
?
`Trace:
${
args
.
join
(
' '
)}
`
:
'Trace'
const
label
=
args
.
length
>
0
?
`Trace:
${
args
.
join
(
' '
)}
`
:
'Trace'
const
traceOutput
=
`
${
label
}
\n
${
traceStack
}
`
const
traceOutput
=
`
${
label
}
\n
${
traceStack
}
`
// Use console.
log with the dimmed trace output
// Use console.
error with the dimmed trace output (outputs to stderr like native trace)
const
dimmedArgs
=
convertToDimmedArgs
(
'
log
'
,
[
traceOutput
])
const
dimmedArgs
=
convertToDimmedArgs
(
'
error
'
,
[
traceOutput
])
if
(
consoleStore
?.
dim
===
true
)
{
if
(
consoleStore
?.
dim
===
true
)
{
return
console
.
log
(...
dimmedArgs
)
as
ReturnType
<
F
>
return
console
.
error
(...
dimmedArgs
)
as
ReturnType
<
F
>
}
else
{
}
else
{
return
consoleAsyncStorage
.
run
(
DIMMED_STORE
,
()
=>
return
consoleAsyncStorage
.
run
(
DIMMED_STORE
,
()
=>
console
.
log
(...
dimmedArgs
)
console
.
error
(...
dimmedArgs
)
)
as
ReturnType
<
F
>
)
as
ReturnType
<
F
>
}
}
}
}
...
...
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