Skip to content

Commit 9bfc070

Browse files
isaacroldangonzaloriestra
authored andcommitted
Remove refreshTokens
1 parent b9d2913 commit 9bfc070

File tree

5 files changed

+24
-76
lines changed

5 files changed

+24
-76
lines changed

packages/app/src/cli/services/app-logs/utils.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,6 @@ export const subscribeToAppLogs = async (
194194
variables: AppLogsSubscribeMutationVariables,
195195
organizationId: string,
196196
): Promise<string> => {
197-
// Refresh the token since it might have expired since the last subscribeToAppLogs request
198-
await developerPlatformClient.refreshToken()
199-
200197
// Now try the subscription with the fresh token
201198
const result = await developerPlatformClient.subscribeToAppLogs(variables, organizationId)
202199

packages/app/src/cli/services/dev.ts

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,14 @@ import {RemoteAwareExtensionSpecification} from '../models/extensions/specificat
3838
import {ports} from '../constants.js'
3939
import {generateCertificate} from '../utilities/mkcert.js'
4040
import {Config} from '@oclif/core'
41-
import {performActionWithRetryAfterRecovery} from '@shopify/cli-kit/common/retry'
4241
import {AbortController} from '@shopify/cli-kit/node/abort'
4342
import {checkPortAvailability, getAvailableTCPPort} from '@shopify/cli-kit/node/tcp'
4443
import {TunnelClient} from '@shopify/cli-kit/node/plugins/tunnel'
4544
import {getBackendPort} from '@shopify/cli-kit/node/environment'
4645
import {basename} from '@shopify/cli-kit/node/path'
4746
import {renderInfo, renderWarning} from '@shopify/cli-kit/node/ui'
4847
import {reportAnalyticsEvent} from '@shopify/cli-kit/node/analytics'
49-
import {OutputProcess, formatPackageManagerCommand, outputDebug} from '@shopify/cli-kit/node/output'
48+
import {OutputProcess, formatPackageManagerCommand} from '@shopify/cli-kit/node/output'
5049
import {hashString} from '@shopify/cli-kit/node/crypto'
5150
import {AbortError} from '@shopify/cli-kit/node/error'
5251

@@ -452,45 +451,17 @@ export function developerPreviewController(
452451
if (developerPlatformClient.supportsDevSessions) {
453452
return {
454453
fetchMode: () => Promise.resolve(false),
455-
enable: () => Promise.resolve(),
454+
enable: () => Promise.resolve(false),
456455
disable: () => Promise.resolve(),
457456
update: () => Promise.resolve(false),
458457
}
459458
}
460459

461-
const refreshToken = async () => {
462-
await developerPlatformClient.refreshToken()
463-
}
464-
465-
const withRefreshToken = async <T>(
466-
fn: (developerPlatformClient: DeveloperPlatformClient) => Promise<T>,
467-
): Promise<T> => {
468-
try {
469-
const result = await performActionWithRetryAfterRecovery(async () => fn(developerPlatformClient), refreshToken)
470-
return result
471-
} catch (err) {
472-
outputDebug('Failed to refresh token')
473-
throw err
474-
}
475-
}
476-
477460
return {
478-
fetchMode: async () =>
479-
withRefreshToken(async (developerPlatformClient: DeveloperPlatformClient) =>
480-
Boolean(await fetchAppPreviewMode(apiKey, developerPlatformClient)),
481-
),
482-
enable: async () =>
483-
withRefreshToken(async (developerPlatformClient: DeveloperPlatformClient) => {
484-
await enableDeveloperPreview({apiKey, developerPlatformClient})
485-
}),
486-
disable: async () =>
487-
withRefreshToken(async (developerPlatformClient: DeveloperPlatformClient) => {
488-
await disableDeveloperPreview({apiKey, developerPlatformClient})
489-
}),
490-
update: async (state: boolean) =>
491-
withRefreshToken(async (developerPlatformClient: DeveloperPlatformClient) =>
492-
developerPreviewUpdate({apiKey, developerPlatformClient, enabled: state}),
493-
),
461+
fetchMode: async () => Boolean(await fetchAppPreviewMode(apiKey, developerPlatformClient)),
462+
enable: async () => enableDeveloperPreview({apiKey, developerPlatformClient}),
463+
disable: async () => disableDeveloperPreview({apiKey, developerPlatformClient}),
464+
update: async (state: boolean) => developerPreviewUpdate({apiKey, developerPlatformClient, enabled: state}),
494465
}
495466
}
496467

packages/app/src/cli/services/dev/processes/dev-session/dev-session.ts

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {DevSessionCreateOptions, DevSessionUpdateOptions} from '../../../../util
77
import {AppManifest} from '../../../../models/app/app.js'
88
import {endHRTimeInMs, startHRTime} from '@shopify/cli-kit/node/hrtime'
99
import {ClientError} from 'graphql-request'
10-
import {performActionWithRetryAfterRecovery} from '@shopify/cli-kit/common/retry'
1110
import {JsonMapType} from '@shopify/cli-kit/node/toml'
1211
import {AbortError} from '@shopify/cli-kit/node/error'
1312
import {isUnitTest} from '@shopify/cli-kit/node/context/local'
@@ -378,26 +377,19 @@ export class DevSession {
378377
* @returns The signed URL
379378
*/
380379
private async getSignedURLWithRetry() {
381-
return performActionWithRetryAfterRecovery(
382-
async () =>
383-
getUploadURL(this.options.developerPlatformClient, {
384-
apiKey: this.options.appId,
385-
organizationId: this.options.organizationId,
386-
id: this.options.appId,
387-
}),
388-
() => this.options.developerPlatformClient.refreshToken(),
389-
)
380+
return getUploadURL(this.options.developerPlatformClient, {
381+
apiKey: this.options.appId,
382+
organizationId: this.options.organizationId,
383+
id: this.options.appId,
384+
})
390385
}
391386

392387
/**
393388
* Update the dev session
394389
* @param payload - The payload to update the dev session with
395390
*/
396391
private async devSessionUpdateWithRetry(payload: DevSessionUpdateOptions): Promise<DevSessionResult> {
397-
const result = await performActionWithRetryAfterRecovery(
398-
async () => this.options.developerPlatformClient.devSessionUpdate(payload),
399-
() => this.options.developerPlatformClient.refreshToken(),
400-
)
392+
const result = await this.options.developerPlatformClient.devSessionUpdate(payload)
401393
const errors = result.devSessionUpdate?.userErrors ?? []
402394
if (errors.length) return {status: 'remote-error', error: errors}
403395
return {status: 'updated'}
@@ -410,10 +402,7 @@ export class DevSession {
410402
* @param payload - The payload to create the dev session with
411403
*/
412404
private async devSessionCreateWithRetry(payload: DevSessionCreateOptions): Promise<DevSessionResult> {
413-
const result = await performActionWithRetryAfterRecovery(
414-
async () => this.options.developerPlatformClient.devSessionCreate(payload),
415-
() => this.options.developerPlatformClient.refreshToken(),
416-
)
405+
const result = await this.options.developerPlatformClient.devSessionCreate(payload)
417406
const errors = result.devSessionCreate?.userErrors ?? []
418407
if (errors.length) return {status: 'remote-error', error: errors}
419408
return {status: 'created'}

packages/app/src/cli/services/dev/processes/draftable-extension.ts

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {getAppIdentifiers} from '../../../models/app/identifiers.js'
77
import {installJavy} from '../../function/build.js'
88
import {DeveloperPlatformClient} from '../../../utilities/developer-platform-client.js'
99
import {AppEvent, AppEventWatcher, EventType} from '../app-events/app-event-watcher.js'
10-
import {performActionWithRetryAfterRecovery} from '@shopify/cli-kit/common/retry'
1110
import {AbortError} from '@shopify/cli-kit/node/error'
1211
import {useConcurrentOutputContext} from '@shopify/cli-kit/node/ui/components'
1312

@@ -35,10 +34,6 @@ export const pushUpdatesForDraftableExtensions: DevProcessFunction<DraftableExte
3534

3635
const draftableExtensions = app.draftableExtensions.map((ext) => ext.handle)
3736

38-
async function refreshToken() {
39-
await developerPlatformClient.refreshToken()
40-
}
41-
4237
const handleAppEvent = async (event: AppEvent) => {
4338
const extensionEvents = event.extensionEvents
4439
.filter((ev) => ev.type === EventType.Updated)
@@ -50,20 +45,16 @@ export const pushUpdatesForDraftableExtensions: DevProcessFunction<DraftableExte
5045
const registrationId = remoteExtensions[extension.localIdentifier]
5146
if (!registrationId) throw new AbortError(`Extension ${extension.localIdentifier} not found on remote app.`)
5247
await useConcurrentOutputContext({outputPrefix: extension.outputPrefix}, async () => {
53-
return performActionWithRetryAfterRecovery(
54-
async () =>
55-
updateExtensionDraft({
56-
extension,
57-
developerPlatformClient,
58-
apiKey,
59-
registrationId,
60-
stdout,
61-
stderr,
62-
appConfiguration: app.configuration,
63-
bundlePath: appWatcher.buildOutputPath,
64-
}),
65-
refreshToken,
66-
)
48+
await updateExtensionDraft({
49+
extension,
50+
developerPlatformClient,
51+
apiKey,
52+
registrationId,
53+
stdout,
54+
stderr,
55+
appConfiguration: app.configuration,
56+
bundlePath: appWatcher.buildOutputPath,
57+
})
6758
})
6859
})
6960
await Promise.all(promises)

packages/app/src/cli/services/dev/ui/components/Dev.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {Writable} from 'stream'
1616

1717
export interface DeveloperPreviewController {
1818
fetchMode: () => Promise<boolean>
19-
enable: () => Promise<void>
19+
enable: () => Promise<boolean>
2020
disable: () => Promise<void>
2121
update: (state: boolean) => Promise<boolean>
2222
}

0 commit comments

Comments
 (0)