axios+telemetry cleanup
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
* when there's a new SHA. Callers decide fallback behavior on failure.
|
||||
*/
|
||||
|
||||
import axios from 'axios'
|
||||
import { chmod, mkdir, readFile, rename, rm, writeFile } from 'fs/promises'
|
||||
import { dirname, join, resolve, sep } from 'path'
|
||||
import { waitForScrollIdle } from '../../bootstrap/state.js'
|
||||
@@ -17,6 +16,7 @@ import { logEvent } from '../../services/analytics/index.js'
|
||||
import { logForDebugging } from '../debug.js'
|
||||
import { parseZipModes, unzipFile } from '../dxt/zip.js'
|
||||
import { errorMessage, getErrnoCode } from '../errors.js'
|
||||
import { isHttpError, nativeRequest } from '../http.js'
|
||||
|
||||
type SafeString = AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
|
||||
|
||||
@@ -78,7 +78,8 @@ export async function fetchOfficialMarketplaceFromGcs(
|
||||
try {
|
||||
// 1. Latest pointer — ~40 bytes, backend sets Cache-Control: no-cache,
|
||||
// max-age=300. Cheap enough to hit every startup.
|
||||
const latest = await axios.get(`${GCS_BASE}/latest`, {
|
||||
const latest = await nativeRequest<string>(`${GCS_BASE}/latest`, {
|
||||
method: 'GET',
|
||||
responseType: 'text',
|
||||
timeout: 10_000,
|
||||
})
|
||||
@@ -104,7 +105,8 @@ export async function fetchOfficialMarketplaceFromGcs(
|
||||
// 3. Download zip and extract to a staging dir, then atomic-swap into
|
||||
// place. Crash mid-extract leaves a .staging dir (next run rm's it)
|
||||
// rather than a half-written installLocation.
|
||||
const zipResp = await axios.get(`${GCS_BASE}/${sha}.zip`, {
|
||||
const zipResp = await nativeRequest<ArrayBuffer>(`${GCS_BASE}/${sha}.zip`, {
|
||||
method: 'GET',
|
||||
responseType: 'arraybuffer',
|
||||
timeout: 60_000,
|
||||
})
|
||||
@@ -194,9 +196,9 @@ const KNOWN_FS_CODES = new Set([
|
||||
* (disk full, permission denied) before flipping the git-fallback kill switch.
|
||||
*/
|
||||
export function classifyGcsError(e: unknown): string {
|
||||
if (axios.isAxiosError(e)) {
|
||||
if (e.code === 'ECONNABORTED') return 'timeout'
|
||||
if (e.response) return `http_${e.response.status}`
|
||||
if (isHttpError(e)) {
|
||||
if (e.message?.includes('timeout')) return 'timeout'
|
||||
if (e.status) return `http_${e.status}`
|
||||
return 'network'
|
||||
}
|
||||
const code = getErrnoCode(e)
|
||||
|
||||
Reference in New Issue
Block a user