From ac66739ce59b3cfc59d0a568d93575435df448f6 Mon Sep 17 00:00:00 2001 From: Alejo Thomas Ortega Date: Fri, 11 Oct 2024 17:56:20 -0300 Subject: [PATCH] fix: scenes forward (#505) * fix: scenes forward * Revert "fix: don't save profiles in s3 bucket (#500)" This reverts commit b74afff2d78c4ce19548a91c8957424d22f40b3b. --- package.json | 2 +- src/adapters/deployer/index.ts | 86 ++++++++++++++++++---------------- 2 files changed, 47 insertions(+), 41 deletions(-) diff --git a/package.json b/package.json index fff5755..7643667 100644 --- a/package.json +++ b/package.json @@ -30,4 +30,4 @@ "@well-known-components/logger": "^3.1.2", "@well-known-components/metrics": "^2.0.1" } -} \ No newline at end of file +} diff --git a/src/adapters/deployer/index.ts b/src/adapters/deployer/index.ts index 61d1eb9..e4337fa 100644 --- a/src/adapters/deployer/index.ts +++ b/src/adapters/deployer/index.ts @@ -25,37 +25,38 @@ export function createDeployerComponent( const isSnsEventToSend = !!components.sns.eventArn - if (exists) { + if (exists || !(isSnsEntityToSend && isSnsEventToSend)) { return await markAsDeployed() } - const deploymentToSqs: DeploymentToSqs = { - entity, - contentServerUrls: servers - } + await components.downloadQueue.onSizeLessThan(1000) - if (isSnsEntityToSend) { - await components.downloadQueue.onSizeLessThan(1000) + void components.downloadQueue.scheduleJob(async () => { + logger.info('Downloading entity', { + entityId: entity.entityId, + entityType: entity.entityType, + servers: servers.join(',') + }) - void components.downloadQueue.scheduleJob(async () => { - logger.info('Downloading entity', { - entityId: entity.entityId, - entityType: entity.entityType, - servers: servers.join(',') - }) + await downloadEntityAndContentFiles( + { ...components, fetcher: components.fetch }, + entity.entityId, + servers, + new Map(), + 'content', + 10, + 1000 + ) - await downloadEntityAndContentFiles( - { ...components, fetcher: components.fetch }, - entity.entityId, - servers, - new Map(), - 'content', - 10, - 1000 - ) + logger.info('Entity stored', { entityId: entity.entityId, entityType: entity.entityType }) + + const deploymentToSqs: DeploymentToSqs = { + entity, + contentServerUrls: servers + } - logger.info('Entity stored', { entityId: entity.entityId, entityType: entity.entityType }) - // send sns + // send sns + if (isSnsEntityToSend) { const receipt = await client.send( new PublishCommand({ TopicArn: components.sns.arn, @@ -66,26 +67,31 @@ export function createDeployerComponent( messageId: receipt.MessageId as any, sequenceNumber: receipt.SequenceNumber as any }) - }) - } + } - if (isSnsEventToSend) { - const receipt = await client.send( - new PublishCommand({ - TopicArn: components.sns.eventArn, - Message: JSON.stringify(deploymentToSqs) + if (isSnsEventToSend) { + const receipt = await client.send( + new PublishCommand({ + TopicArn: components.sns.eventArn, + Message: JSON.stringify(deploymentToSqs) + }) + ) + logger.info('Notification sent to events SNS', { + MessageId: receipt.MessageId as any, + SequenceNumber: receipt.SequenceNumber as any }) - ) - logger.info('Notification sent to events SNS', { - messageId: receipt.MessageId as any, - sequenceNumber: receipt.SequenceNumber as any, - entityId: deploymentToSqs.entity.entityId - }) - } - - await markAsDeployed() + } + await markAsDeployed() + }) } catch (error: any) { const isNotRetryable = /status: 4\d{2}/.test(error.message) + logger.error('Failed to publish entity', { + entityId: entity.entityId, + entityType: entity.entityType, + error: error?.message, + stack: error?.stack + }) + if (isNotRetryable) { logger.error('Failed to download entity', { entityId: entity.entityId,