Skip to content

Commit

Permalink
fix(upload-client): fix h2+ detection
Browse files Browse the repository at this point in the history
  • Loading branch information
talentlessguy committed Feb 20, 2025
1 parent 9da36a4 commit 7d531f1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/upload-client/src/fetch-with-upload-progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,11 @@ const isBrowser = typeof globalThis.XMLHttpRequest !== 'undefined'
export const fetchWithUploadProgress = (url, init = {}) => {
// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/nextHopProtocol
/**
* @type {string}
* @type {string | undefined}
*/
// @ts-expect-error nextHopProtocol is missing from types but is widely available
const protocol = performance.getEntriesByType('resource')[0].nextHopProtocol

const preH2 = protocol.startsWith('http')
const protocol = !!performance.getEntriesByType('resource')[0]?.nextHopProtocol
const preH2 = protocol !== 'h2' && protocol !== 'h2c' && protocol !== 'h3'

if ((isBrowser || preH2) && !isNode) {
return fetchXhr(url, init)
Expand Down

0 comments on commit 7d531f1

Please # to comment.