Skip to content

Commit

Permalink
PROTO-1335: relay upload delay (#6281)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecsavvy committed Oct 19, 2023
1 parent 8282ec2 commit 2392f77
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,20 @@ export class DiscoveryNodeSelector implements DiscoveryNodeSelectorService {
}
})
} else {
const userError = response !== undefined && response.status < 500

if (userError) {
this.logger.warn(`status code ${response.status} below 500, not reselecting`, endpoint, context)
return response
}
return await this.reselectAndRetry({ context, endpoint })
}
return response
},
onError: async (context: ErrorContext) => {
const endpoint = await this.getSelectedEndpoint()
const response = context.response

if (!endpoint) {
await this.select(endpoint)
} else {
Expand Down
30 changes: 22 additions & 8 deletions packages/web/src/common/store/upload/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import {
fork,
cancel,
all,
getContext
getContext,
delay
} from 'redux-saga/effects'

import { make } from 'common/store/analytics/actions'
Expand Down Expand Up @@ -796,6 +797,7 @@ function* uploadCollection(tracks, userId, collectionMetadata, isAlbum) {
`Could not confirm playlist creation for playlist id ${playlistId}`
)
}

return (yield call(audiusBackendInstance.getPlaylists, userId, [
playlistId
]))[0]
Expand Down Expand Up @@ -1010,14 +1012,25 @@ function* uploadSingleTrack(track) {
throw new Error(`Could not confirm upload single track ${trackId}`)
}

return yield apiClient.getTrack({
id: trackId,
currentUserId: userId,
unlistedArgs: {
urlTitle: formatUrlName(track.metadata.title),
handle
let retries = 30
while (retries !== 0) {
const maybeTrackRes = yield apiClient.getTrack({
id: trackId,
currentUserId: userId,
unlistedArgs: {
urlTitle: formatUrlName(track.metadata.title),
handle
}
})
if (maybeTrackRes !== undefined && maybeTrackRes !== null) {
return maybeTrackRes
}
})
// lil bit of delay for retries
yield delay(1500)
retries -= 1
}

throw new Error(`Exhausted retries querying for track ${trackId}`)
},
function* onSuccess(confirmedTrack) {
yield call(responseChan.put, { confirmedTrack })
Expand Down Expand Up @@ -1087,6 +1100,7 @@ function* uploadSingleTrack(track) {
status: ProgressStatus.COMPLETE
})
)

yield put(
uploadActions.uploadTracksSucceeded(confirmedTrack.track_id, [
confirmedTrack
Expand Down

0 comments on commit 2392f77

Please sign in to comment.