Unverified Commit 96484750 authored by Balázs Orbán's avatar Balázs Orbán Committed by GitHub

chore: hide version info parse error (#62084)

### 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)
parent 9572dfd8
...@@ -191,6 +191,14 @@ function erroredPages(compilation: webpack.Compilation) { ...@@ -191,6 +191,14 @@ function erroredPages(compilation: webpack.Compilation) {
return failedPages return failedPages
} }
const networkErrors = [
'EADDRINFO',
'ENOTFOUND',
'ETIMEDOUT',
'ECONNREFUSED',
'EAI_AGAIN',
]
export async function getVersionInfo(enabled: boolean): Promise<VersionInfo> { export async function getVersionInfo(enabled: boolean): Promise<VersionInfo> {
let installed = '0.0.0' let installed = '0.0.0'
...@@ -206,15 +214,11 @@ export async function getVersionInfo(enabled: boolean): Promise<VersionInfo> { ...@@ -206,15 +214,11 @@ export async function getVersionInfo(enabled: boolean): Promise<VersionInfo> {
if (!res.ok) return { installed, staleness: 'unknown' } if (!res.ok) return { installed, staleness: 'unknown' }
const tags = await res.json() const { latest, canary } = await res.json()
return parseVersionInfo({ return parseVersionInfo({ installed, latest, canary })
installed, } catch (e: any) {
latest: tags.latest, if (!networkErrors.includes(e?.code)) console.error(e)
canary: tags.canary,
})
} catch (e) {
console.error('parse version e', e)
return { installed, staleness: 'unknown' } return { installed, staleness: 'unknown' }
} }
} }
......
...@@ -4,13 +4,9 @@ import { FileRef, nextTestSetup } from 'e2e-utils' ...@@ -4,13 +4,9 @@ import { FileRef, nextTestSetup } from 'e2e-utils'
import path from 'path' import path from 'path'
import { outdent } from 'outdent' import { outdent } from 'outdent'
describe.skip('Error Overlay version staleness', () => { describe('Error Overlay version staleness', () => {
const { next } = nextTestSetup({ const { next } = nextTestSetup({
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')), files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
dependencies: {
react: 'latest',
'react-dom': 'latest',
},
skipStart: true, skipStart: true,
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment