axios+telemetry cleanup
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
* └── marketplace.json
|
||||
*/
|
||||
|
||||
import axios from 'axios'
|
||||
import { writeFile } from 'fs/promises'
|
||||
import isEqual from 'lodash-es/isEqual.js'
|
||||
import memoize from 'lodash-es/memoize.js'
|
||||
@@ -36,6 +35,7 @@ import {
|
||||
import { execFileNoThrow, execFileNoThrowWithCwd } from '../execFileNoThrow.js'
|
||||
import { getFsImplementation } from '../fsOperations.js'
|
||||
import { gitExe } from '../git.js'
|
||||
import { isHttpError, nativeRequest } from '../http.js'
|
||||
import { logError } from '../log.js'
|
||||
import {
|
||||
getInitialSettings,
|
||||
@@ -1279,7 +1279,8 @@ async function cacheMarketplaceFromUrl(
|
||||
let response
|
||||
const fetchStarted = performance.now()
|
||||
try {
|
||||
response = await axios.get(url, {
|
||||
response = await nativeRequest(url, {
|
||||
method: 'GET',
|
||||
timeout: 10000,
|
||||
headers,
|
||||
})
|
||||
@@ -1291,20 +1292,15 @@ async function cacheMarketplaceFromUrl(
|
||||
performance.now() - fetchStarted,
|
||||
classifyFetchError(error),
|
||||
)
|
||||
if (axios.isAxiosError(error)) {
|
||||
if (error.code === 'ECONNREFUSED' || error.code === 'ENOTFOUND') {
|
||||
throw new Error(
|
||||
`Could not connect to ${redactedUrl}. Please check your internet connection and verify the URL is correct.\n\nTechnical details: ${error.message}`,
|
||||
)
|
||||
}
|
||||
if (error.code === 'ETIMEDOUT') {
|
||||
if (isHttpError(error)) {
|
||||
if (error.message?.includes('timeout')) {
|
||||
throw new Error(
|
||||
`Request timed out while downloading marketplace from ${redactedUrl}. The server may be slow or unreachable.\n\nTechnical details: ${error.message}`,
|
||||
)
|
||||
}
|
||||
if (error.response) {
|
||||
if (error.status) {
|
||||
throw new Error(
|
||||
`HTTP ${error.response.status} error while downloading marketplace from ${redactedUrl}. The marketplace file may not exist at this URL.\n\nTechnical details: ${error.message}`,
|
||||
`HTTP ${error.status} error while downloading marketplace from ${redactedUrl}. The marketplace file may not exist at this URL.\n\nTechnical details: ${error.message}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user