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
8f0acdf7
Unverified
Commit
8f0acdf7
authored
Jan 18, 2023
by
JJ Kasper
Committed by
GitHub
Jan 18, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gracefully handle telemetry not being available (#44986)
parent
6d09f0b8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
32 additions
and
13 deletions
+32
-13
middleware-plugin.ts
packages/next/src/build/webpack/plugins/middleware-plugin.ts
+3
-3
swc-load-failure.ts
packages/next/src/telemetry/events/swc-load-failure.ts
+1
-1
to-telemetry.ts
packages/next/src/trace/report/to-telemetry.ts
+2
-1
shared.ts
packages/next/src/trace/shared.ts
+8
-1
utils.ts
test/e2e/yarn-pnp/test/utils.ts
+13
-4
with-eslint.test.ts
test/e2e/yarn-pnp/test/with-eslint.test.ts
+1
-1
with-mdx.test.ts
test/e2e/yarn-pnp/test/with-mdx.test.ts
+1
-1
with-next-sass.test.ts
test/e2e/yarn-pnp/test/with-next-sass.test.ts
+3
-1
No files found.
packages/next/src/build/webpack/plugins/middleware-plugin.ts
View file @
8f0acdf7
...
...
@@ -607,7 +607,7 @@ function getExtractMetadata(params: {
return
async
()
=>
{
metadataByEntry
.
clear
()
const
resolver
=
compilation
.
resolverFactory
.
get
(
'normal'
)
const
telemetry
:
Telemetry
=
traceGlobals
.
get
(
'telemetry'
)
const
telemetry
:
Telemetry
|
undefined
=
traceGlobals
.
get
(
'telemetry'
)
for
(
const
[
entryName
,
entry
]
of
compilation
.
entries
)
{
if
(
entry
.
options
.
runtime
!==
EDGE_RUNTIME_WEBPACK
)
{
...
...
@@ -683,7 +683,7 @@ function getExtractMetadata(params: {
}
if
(
edgeFunctionConfig
?.
config
?.
unstable_allowDynamicGlobs
)
{
telemetry
.
record
({
telemetry
?
.
record
({
eventName
:
'NEXT_EDGE_ALLOW_DYNAMIC_USED'
,
payload
:
{
...
edgeFunctionConfig
,
...
...
@@ -773,7 +773,7 @@ function getExtractMetadata(params: {
}
}
telemetry
.
record
({
telemetry
?
.
record
({
eventName
:
EVENT_BUILD_FEATURE_USAGE
,
payload
:
{
featureName
:
'vercelImageGeneration'
,
...
...
packages/next/src/telemetry/events/swc-load-failure.ts
View file @
8f0acdf7
...
...
@@ -20,7 +20,7 @@ export type EventSwcLoadFailure = {
export
async
function
eventSwcLoadFailure
(
event
?:
EventSwcLoadFailure
[
'payload'
]
):
Promise
<
void
>
{
const
telemetry
:
Telemetry
=
traceGlobals
.
get
(
'telemetry'
)
const
telemetry
:
Telemetry
|
undefined
=
traceGlobals
.
get
(
'telemetry'
)
// can't continue if telemetry isn't set
if
(
!
telemetry
)
return
...
...
packages/next/src/trace/report/to-telemetry.ts
View file @
8f0acdf7
import
{
Telemetry
}
from
'../../telemetry/storage'
import
{
traceGlobals
}
from
'../shared'
const
TRACE_EVENT_ACCESSLIST
=
new
Map
(
...
...
@@ -11,7 +12,7 @@ const reportToTelemetry = (spanName: string, duration: number) => {
if
(
!
eventName
)
{
return
}
const
telemetry
=
traceGlobals
.
get
(
'telemetry'
)
const
telemetry
:
Telemetry
|
undefined
=
traceGlobals
.
get
(
'telemetry'
)
if
(
!
telemetry
)
{
return
}
...
...
packages/next/src/trace/shared.ts
View file @
8f0acdf7
export
type
SpanId
=
number
export
const
traceGlobals
:
Map
<
any
,
any
>
=
new
Map
()
let
_traceGlobals
:
Map
<
any
,
any
>
=
(
global
as
any
).
_traceGlobals
if
(
!
_traceGlobals
)
{
_traceGlobals
=
new
Map
()
}
;(
global
as
any
).
_traceGlobals
=
_traceGlobals
export
const
traceGlobals
:
Map
<
any
,
any
>
=
_traceGlobals
export
const
setGlobal
=
(
key
:
any
,
val
:
any
)
=>
{
traceGlobals
.
set
(
key
,
val
)
}
test/e2e/yarn-pnp/test/utils.ts
View file @
8f0acdf7
...
...
@@ -6,7 +6,11 @@ import { NextInstance } from 'test/lib/next-modes/base'
jest
.
setTimeout
(
2
*
60
*
1000
)
export
function
runTests
(
example
=
''
)
{
export
function
runTests
(
example
=
''
,
testPath
=
'/'
,
expectedContent
=
[
'index page'
]
)
{
const
versionParts
=
process
.
versions
.
node
.
split
(
'.'
).
map
((
i
)
=>
Number
(
i
))
if
((
global
as
any
).
isNextDeploy
)
{
...
...
@@ -42,7 +46,7 @@ export function runTests(example = '') {
prev
.
push
(
`
${
cur
}
@
${
dependencies
[
cur
]}
`
)
return
prev
},
[]
as
string
[])
return
`yarn set version
4.0.0-rc.13
&& yarn config set enableGlobalCache true && yarn config set compressionLevel 0 && yarn add
${
pkgs
.
join
(
return
`yarn set version
berry
&& yarn config set enableGlobalCache true && yarn config set compressionLevel 0 && yarn add
${
pkgs
.
join
(
' '
)}
`
},
...
...
@@ -55,9 +59,14 @@ export function runTests(example = '') {
afterAll
(()
=>
next
?.
destroy
())
it
(
`should compile and serve the index page correctly
${
example
}
`
,
async
()
=>
{
const
res
=
await
fetchViaHTTP
(
next
.
url
,
'/'
)
const
res
=
await
fetchViaHTTP
(
next
.
url
,
testPath
)
expect
(
res
.
status
).
toBe
(
200
)
expect
(
await
res
.
text
()).
toContain
(
'<html'
)
const
text
=
await
res
.
text
()
for
(
const
content
of
expectedContent
)
{
expect
(
text
).
toContain
(
content
)
}
})
}
else
{
it
(
'should not run PnP test for older node versions'
,
()
=>
{})
...
...
test/e2e/yarn-pnp/test/with-eslint.test.ts
View file @
8f0acdf7
import
{
runTests
}
from
'./utils'
describe
(
'yarn PnP'
,
()
=>
{
runTests
(
'with-eslint'
)
runTests
(
'with-eslint'
,
'/'
,
[
'<html'
,
'Home'
,
'fake-script'
]
)
})
test/e2e/yarn-pnp/test/with-mdx.test.ts
View file @
8f0acdf7
import
{
runTests
}
from
'./utils'
describe
(
'yarn PnP'
,
()
=>
{
runTests
(
'with-mdx'
)
runTests
(
'with-mdx'
,
'/'
,
[
'Look, a button'
,
'Hello'
]
)
})
test/e2e/yarn-pnp/test/with-next-sass.test.ts
View file @
8f0acdf7
import
{
runTests
}
from
'./utils'
describe
(
'yarn PnP'
,
()
=>
{
runTests
(
'with-next-sass'
)
runTests
(
'with-next-sass'
,
'/'
,
[
'Hello World, I am being styled using SCSS Modules'
,
])
})
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