Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/common/src/models/Analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1089,12 +1089,13 @@ type TrackUploadStartUploading = {
type TrackUploadTrackUploading = {
eventName: Name.TRACK_UPLOAD_TRACK_UPLOADING
artworkSource: 'unsplash' | 'original'
genre: string
mood: string
downloadable: 'yes' | 'no' | 'follow'
trackId: number
size: number
type: string
fileType: string
name: string
genre: string
mood?: string
}
type TrackUploadCompleteUpload = {
eventName: Name.TRACK_UPLOAD_COMPLETE_UPLOAD
Expand Down Expand Up @@ -2194,7 +2195,7 @@ type StripeSessionCreationError = StripeEventFields & {
eventName: Name.STRIPE_SESSION_CREATION_ERROR
code: string
stripeErrorMessage: string
type: string
kind: string
}

type StripeSessionCreated = StripeEventFields & {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/store/ui/stripe-modal/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function* handleInitializeStripeModal({
code,
destinationCurrency,
stripeErrorMessage,
type
kind: type
})
)
}
Expand Down
21 changes: 19 additions & 2 deletions packages/sdk/src/sdk/services/Storage/Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import type {
} from './types'

const MAX_TRACK_TRANSCODE_TIMEOUT = 3600000 // 1 hour
const MAX_IMAGE_RESIZE_TIMEOUT_MS = 5 * 60_000 // 5 minutes
const MAX_TRACK_TRANSCODE_NO_PROGRESS_TIMEOUT = 600000 // 10 minutes
const MAX_IMAGE_RESIZE_TIMEOUT_MS = 300000 // 5 minutes
const POLL_STATUS_INTERVAL = 3000 // 3s

export class Storage implements StorageService {
Expand Down Expand Up @@ -180,6 +181,8 @@ export class Storage implements StorageService {
onProgress?: ProgressHandler
) {
const start = Date.now()
let lastProgressUpdate = Date.now()
let lastTranscodeProgress = 0

const maxPollingMs =
template === 'audio'
Expand All @@ -190,6 +193,19 @@ export class Storage implements StorageService {
try {
const resp = await this.getProcessingStatus(id)
if (template === 'audio' && resp.transcode_progress) {
// Only update lastProgressUpdate if the progress has increased
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

if (resp.transcode_progress > lastTranscodeProgress) {
lastProgressUpdate = Date.now()
lastTranscodeProgress = resp.transcode_progress
} else if (
Date.now() - lastProgressUpdate >
MAX_TRACK_TRANSCODE_NO_PROGRESS_TIMEOUT
) {
throw new Error(
`No transcoding progress increase for ${MAX_TRACK_TRANSCODE_NO_PROGRESS_TIMEOUT}ms. Progress stuck at ${lastTranscodeProgress}. id=${id}`
)
}

onProgress?.({
audio: {
transcode: { decimal: resp.transcode_progress }
Expand All @@ -208,9 +224,10 @@ export class Storage implements StorageService {
)
}
} catch (e: any) {
// Rethrow if error is "Upload failed" or if status code is 422 (Unprocessable Entity)
// Rethrow if error is "Upload failed", stalled, or if status code is 422 (Unprocessable Entity)
if (
e.message?.startsWith('Upload failed') ||
e.message?.startsWith('No transcoding progress increase') ||
(e.response && e.response?.status === 422)
) {
throw e
Expand Down
26 changes: 19 additions & 7 deletions packages/web/src/common/store/upload/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ import {
replaceTrackProgressModalActions,
queueSelectors,
queueActions,
playerActions
playerActions,
BatchCachedTracks
} from '@audius/common/store'
import {
actionChannelDispatcher,
Expand Down Expand Up @@ -429,7 +430,7 @@ export function* handleUploads({
// Channel to listen for responses
const responseChannel = yield* call(
channel<UploadTrackResponse>,
buffers.expanding(10)
buffers.expanding(200)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh not sure this makes any difference - the expanding means it grows anyway

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm concerned that under the hood in react native something weird happens with this, but i agree low probability this works

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just don't understand why this complexity is even necessary in this codebase in general

)

// Channel to relay progress actions
Expand All @@ -453,10 +454,11 @@ export function* handleUploads({
track.metadata.artwork && 'source' in track.metadata.artwork
? track.metadata.artwork?.source
: undefined,
trackId: track.metadata.track_id,
genre: track.metadata.genre,
moode: track.metadata.mood,
size: track.file.size,
type: track.file.type,
fileType: track.file.type,
name: track.file.name,
downloadable: isContentFollowGated(track.metadata.download_conditions)
? 'follow'
Expand Down Expand Up @@ -1072,10 +1074,20 @@ export function* uploadMultipleTracks(
})

// Get true track metadatas back
const newTracks = yield* call(retrieveTracks, {
trackIds,
forceRetrieveFromSource: true
})
// Allow for retries in case the tracks are not immediately available
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this possible?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be? technically the confirmer is only waiting for block numbers

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the indexer passed the block number that the uploads went in on, the track should be there... Also I think in most cases we see this error the tracks didnt upload successfully

let retries = 20
let newTracks: BatchCachedTracks[] = []
while (retries > 0) {
newTracks = yield* call(retrieveTracks, {
trackIds,
forceRetrieveFromSource: true
})
if (newTracks.length > 0) {
break
}
yield* delay(2000)
retries--
}
if (newTracks.length === 0) {
throw new Error('No tracks found after uploading.')
}
Expand Down