Skip to content

Commit

Permalink
chore: hide version info parse error (#62084)
Browse files Browse the repository at this point in the history
### What?

Currently, if the network call to the
`https://registry.npmjs.org/-/package/next/dist-tags` endpoint fails,
the error is still logged to the terminal.

### Why?

This might be unnecessary as it is likely unactionable and only creates
noise for the user.

### How?

Drop the logging of the error if it's network-related, but log as before
otherwise.
I.e: any other error should still show up:


![image](https://github.com/vercel/next.js/assets/18369201/1e01fe35-aed9-418c-8e0e-f4ee34624eb5)

I also re-enabled some related tests that were skipped.

Closes NEXT-2393

[Slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1707326242303969)
  • Loading branch information
balazsorban44 committed Feb 15, 2024
1 parent 9572dfd commit 9648475
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
20 changes: 12 additions & 8 deletions packages/next/src/server/dev/hot-reloader-webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ function erroredPages(compilation: webpack.Compilation) {
return failedPages
}

const networkErrors = [
'EADDRINFO',
'ENOTFOUND',
'ETIMEDOUT',
'ECONNREFUSED',
'EAI_AGAIN',
]

export async function getVersionInfo(enabled: boolean): Promise<VersionInfo> {
let installed = '0.0.0'

Expand All @@ -206,15 +214,11 @@ export async function getVersionInfo(enabled: boolean): Promise<VersionInfo> {

if (!res.ok) return { installed, staleness: 'unknown' }

const tags = await res.json()
const { latest, canary } = await res.json()

return parseVersionInfo({
installed,
latest: tags.latest,
canary: tags.canary,
})
} catch (e) {
console.error('parse version e', e)
return parseVersionInfo({ installed, latest, canary })
} catch (e: any) {
if (!networkErrors.includes(e?.code)) console.error(e)
return { installed, staleness: 'unknown' }
}
}
Expand Down
6 changes: 1 addition & 5 deletions test/development/acceptance-app/version-staleness.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ import { FileRef, nextTestSetup } from 'e2e-utils'
import path from 'path'
import { outdent } from 'outdent'

describe.skip('Error Overlay version staleness', () => {
describe('Error Overlay version staleness', () => {
const { next } = nextTestSetup({
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
dependencies: {
react: 'latest',
'react-dom': 'latest',
},
skipStart: true,
})

Expand Down

0 comments on commit 9648475

Please sign in to comment.