Skip to content

Commit 1f6eef3

Browse files
authored
fix(build): avoid Turbopack chunk collision with GCS path rename (#7593)
1 parent 3a23820 commit 1f6eef3

6 files changed

Lines changed: 45 additions & 20 deletions

File tree

apps/sim/lib/uploads/core/storage-client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ export async function getFileMetadata(
8484
* absence, because GCS answers a missing object and a missing bucket the same
8585
* way and only the caller's own bucket configuration separates them.
8686
*/
87-
const { getGcsObjectMetadata } = await import('@/lib/uploads/providers/gcs/client')
87+
const { getGcsObjectMetadata } = await import(
88+
'@/lib/uploads/providers/google-cloud-storage/client'
89+
)
8890
return getGcsObjectMetadata(
8991
key,
9092
customConfig?.bucket ? { bucket: customConfig.bucket } : undefined

apps/sim/lib/uploads/core/storage-service.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import {
1111
} from '@/lib/uploads/config'
1212
import { LOCAL_UPLOAD_METADATA_SUFFIX } from '@/lib/uploads/core/storage-key'
1313
import type { AzureMultipartPart, BlobConfig } from '@/lib/uploads/providers/blob/types'
14-
import type { GcsConfig, GcsMultipartPart } from '@/lib/uploads/providers/gcs/types'
14+
import type {
15+
GcsConfig,
16+
GcsMultipartPart,
17+
} from '@/lib/uploads/providers/google-cloud-storage/types'
1518
import type { S3Config, S3MultipartPart } from '@/lib/uploads/providers/s3/types'
1619
import type {
1720
DeleteFileOptions,
@@ -208,7 +211,7 @@ export async function uploadFile(options: UploadFileOptions): Promise<FileInfo>
208211
}
209212

210213
if (USE_GCS_STORAGE) {
211-
const { uploadToGcs } = await import('@/lib/uploads/providers/gcs/client')
214+
const { uploadToGcs } = await import('@/lib/uploads/providers/google-cloud-storage/client')
212215
const uploadResult = await uploadToGcs(
213216
file,
214217
keyToUse,
@@ -379,7 +382,7 @@ async function createGcsBackend(
379382
uploadGcsPart,
380383
completeGcsMultipartUpload,
381384
abortGcsMultipartUpload,
382-
} = await import('@/lib/uploads/providers/gcs/client')
385+
} = await import('@/lib/uploads/providers/google-cloud-storage/client')
383386
const { uploadId, key: uploadKey } = await initiateGcsMultipartUpload({
384387
fileName: key,
385388
contentType,
@@ -553,7 +556,9 @@ export async function downloadFile(options: DownloadFileOptions): Promise<Buffer
553556
}
554557

555558
if (USE_GCS_STORAGE) {
556-
const { downloadFromGcs } = await import('@/lib/uploads/providers/gcs/client')
559+
const { downloadFromGcs } = await import(
560+
'@/lib/uploads/providers/google-cloud-storage/client'
561+
)
557562
const gcsConfig = createGcsConfig(config)
558563
return downloadFromGcs(key, gcsConfig, maxBytes, signal)
559564
}
@@ -611,7 +616,9 @@ export async function downloadFileStream(options: {
611616
}
612617

613618
if (USE_GCS_STORAGE) {
614-
const { downloadFromGcsStream } = await import('@/lib/uploads/providers/gcs/client')
619+
const { downloadFromGcsStream } = await import(
620+
'@/lib/uploads/providers/google-cloud-storage/client'
621+
)
615622
return downloadFromGcsStream(key, createGcsConfig(config))
616623
}
617624

@@ -641,7 +648,7 @@ export async function deleteFile(options: DeleteFileOptions): Promise<void> {
641648
}
642649

643650
if (USE_GCS_STORAGE) {
644-
const { deleteFromGcs } = await import('@/lib/uploads/providers/gcs/client')
651+
const { deleteFromGcs } = await import('@/lib/uploads/providers/google-cloud-storage/client')
645652
return deleteFromGcs(key, createGcsConfig(config))
646653
}
647654
}
@@ -721,7 +728,7 @@ export async function headObject(
721728
}
722729

723730
if (USE_GCS_STORAGE) {
724-
const { headGcsObject } = await import('@/lib/uploads/providers/gcs/client')
731+
const { headGcsObject } = await import('@/lib/uploads/providers/google-cloud-storage/client')
725732
return headGcsObject(key, createGcsConfig(config))
726733
}
727734

@@ -759,7 +766,9 @@ export async function generatePresignedDownloadUrl(
759766
}
760767

761768
if (USE_GCS_STORAGE) {
762-
const { getPresignedUrlWithConfig } = await import('@/lib/uploads/providers/gcs/client')
769+
const { getPresignedUrlWithConfig } = await import(
770+
'@/lib/uploads/providers/google-cloud-storage/client'
771+
)
763772
return getPresignedUrlWithConfig(key, createGcsConfig(config), expirationSeconds)
764773
}
765774

apps/sim/lib/uploads/providers/gcs/client.test.ts renamed to apps/sim/lib/uploads/providers/google-cloud-storage/client.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ import {
8484
resetGcsClientForTesting,
8585
uploadGcsPart,
8686
uploadToGcs,
87-
} from '@/lib/uploads/providers/gcs/client'
87+
} from '@/lib/uploads/providers/google-cloud-storage/client'
8888

8989
const mockFetch = vi.fn()
9090

apps/sim/lib/uploads/providers/gcs/client.ts renamed to apps/sim/lib/uploads/providers/google-cloud-storage/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type {
1414
GcsMultipartPart,
1515
GcsMultipartUploadInit,
1616
GcsPartUploadUrl,
17-
} from '@/lib/uploads/providers/gcs/types'
17+
} from '@/lib/uploads/providers/google-cloud-storage/types'
1818
import type {
1919
FileInfo,
2020
MultipartCompletionPolicy,
File renamed without changes.

apps/sim/lib/uploads/upload-session/provider.ts

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ export async function initiateMultipartProviderUpload(params: {
140140
return { provider, providerUploadId: result.uploadId }
141141
}
142142
if (provider === 'gcs') {
143-
const { initiateGcsMultipartUpload } = await import('@/lib/uploads/providers/gcs/client')
143+
const { initiateGcsMultipartUpload } = await import(
144+
'@/lib/uploads/providers/google-cloud-storage/client'
145+
)
144146
const result = await initiateGcsMultipartUpload({
145147
fileName: params.fileName,
146148
contentType: params.contentType,
@@ -229,7 +231,9 @@ export async function createPutProviderTransfer(params: {
229231
})
230232
return { method: 'put', ...transfer, expiresAt: signedExpiresAt }
231233
}
232-
const { getGcsPresignedUploadUrl } = await import('@/lib/uploads/providers/gcs/client')
234+
const { getGcsPresignedUploadUrl } = await import(
235+
'@/lib/uploads/providers/google-cloud-storage/client'
236+
)
233237
const transfer = await getGcsPresignedUploadUrl(
234238
params.key,
235239
params.contentType,
@@ -307,7 +311,9 @@ export async function getMultipartProviderPartUrls(params: {
307311
expiresAt,
308312
}))
309313
}
310-
const { getGcsMultipartPartUrls } = await import('@/lib/uploads/providers/gcs/client')
314+
const { getGcsMultipartPartUrls } = await import(
315+
'@/lib/uploads/providers/google-cloud-storage/client'
316+
)
311317
const urls = await getGcsMultipartPartUrls(
312318
params.key,
313319
params.providerUploadId,
@@ -341,7 +347,9 @@ export async function listMultipartProviderParts(params: {
341347
const { listMultipartParts } = await import('@/lib/uploads/providers/blob/client')
342348
return listMultipartParts(params.key, createBlobConfig(config))
343349
}
344-
const { listGcsMultipartParts } = await import('@/lib/uploads/providers/gcs/client')
350+
const { listGcsMultipartParts } = await import(
351+
'@/lib/uploads/providers/google-cloud-storage/client'
352+
)
345353
return listGcsMultipartParts(params.key, params.providerUploadId, createGcsConfig(config))
346354
}
347355

@@ -397,7 +405,9 @@ export async function completeMultipartProviderUpload(params: {
397405
)
398406
return
399407
}
400-
const { completeGcsMultipartUpload } = await import('@/lib/uploads/providers/gcs/client')
408+
const { completeGcsMultipartUpload } = await import(
409+
'@/lib/uploads/providers/google-cloud-storage/client'
410+
)
401411
await completeGcsMultipartUpload(
402412
params.key,
403413
params.providerUploadId,
@@ -425,8 +435,8 @@ export async function headProviderObject(params: {
425435
? await import('@/lib/uploads/providers/blob/client').then(({ headBlobObject }) =>
426436
headBlobObject(params.key, createBlobConfig(config))
427437
)
428-
: await import('@/lib/uploads/providers/gcs/client').then(({ headGcsObject }) =>
429-
headGcsObject(params.key, createGcsConfig(config))
438+
: await import('@/lib/uploads/providers/google-cloud-storage/client').then(
439+
({ headGcsObject }) => headGcsObject(params.key, createGcsConfig(config))
430440
)
431441
if (!head) return null
432442
if (!head.contentType || !head.uploadId || !head.version) {
@@ -469,7 +479,9 @@ export async function deleteProviderObjectVersion(params: {
469479
})
470480
return
471481
}
472-
const { deleteGcsObjectVersion } = await import('@/lib/uploads/providers/gcs/client')
482+
const { deleteGcsObjectVersion } = await import(
483+
'@/lib/uploads/providers/google-cloud-storage/client'
484+
)
473485
await deleteGcsObjectVersion({
474486
key: params.key,
475487
generation: params.version,
@@ -502,7 +514,9 @@ export async function abortProviderUpload(params: {
502514
const { abortMultipartUpload } = await import('@/lib/uploads/providers/blob/client')
503515
await abortMultipartUpload(params.key, params.uploadId, createBlobConfig(config))
504516
} else {
505-
const { abortGcsMultipartUpload } = await import('@/lib/uploads/providers/gcs/client')
517+
const { abortGcsMultipartUpload } = await import(
518+
'@/lib/uploads/providers/google-cloud-storage/client'
519+
)
506520
await abortGcsMultipartUpload(params.key, params.providerUploadId, createGcsConfig(config))
507521
}
508522
}

0 commit comments

Comments
 (0)