From 62aa373d916926591f47a9e7d39de1d2ed1fbf02 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 17 Jun 2026 14:44:35 -0400 Subject: [PATCH 1/2] chore(recording-api): fix aws error handling --- .../session-replay/recording-api/recording-service.ts | 4 ++-- .../shared/keystore/dynamodb-keystore.ts | 10 ++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/nodejs/src/session-replay/recording-api/recording-service.ts b/nodejs/src/session-replay/recording-api/recording-service.ts index 74da08c4e945..bf660f522aae 100644 --- a/nodejs/src/session-replay/recording-api/recording-service.ts +++ b/nodejs/src/session-replay/recording-api/recording-service.ts @@ -1,4 +1,4 @@ -import { GetObjectCommand, NoSuchKey, S3Client } from '@aws-sdk/client-s3' +import { GetObjectCommand, S3Client } from '@aws-sdk/client-s3' import { ClickHouseClient } from '@clickhouse/client' import snappy from 'snappy' @@ -136,7 +136,7 @@ export class RecordingService { ) return { ok: true, data: result } } catch (error) { - if (error instanceof NoSuchKey) { + if ((error as Error)?.name === 'NoSuchKey') { logger.warn('[RecordingService] S3 object not found (NoSuchKey)', { key, teamId, diff --git a/nodejs/src/session-replay/shared/keystore/dynamodb-keystore.ts b/nodejs/src/session-replay/shared/keystore/dynamodb-keystore.ts index f2b75e7c4d75..00131dfa98b1 100644 --- a/nodejs/src/session-replay/shared/keystore/dynamodb-keystore.ts +++ b/nodejs/src/session-replay/shared/keystore/dynamodb-keystore.ts @@ -1,10 +1,4 @@ -import { - ConditionalCheckFailedException, - DynamoDBClient, - GetItemCommand, - PutItemCommand, - UpdateItemCommand, -} from '@aws-sdk/client-dynamodb' +import { DynamoDBClient, GetItemCommand, PutItemCommand, UpdateItemCommand } from '@aws-sdk/client-dynamodb' import { DecryptCommand, GenerateDataKeyCommand, KMSClient } from '@aws-sdk/client-kms' import sodium from 'libsodium-wrappers' @@ -65,7 +59,7 @@ export class DynamoDBKeyStore implements KeyStore { }) ) } catch (error) { - if (error instanceof ConditionalCheckFailedException) { + if ((error as Error)?.name === 'ConditionalCheckFailedException') { // Key already exists — return the existing key instead of overwriting return this.getKey(sessionId, teamId) } From 642c032d6162d9ae2131cb779a30a9ae40d6dab3 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 17 Jun 2026 15:03:33 -0400 Subject: [PATCH 2/2] updates --- .../recording-api/recording-service.ts | 4 ++-- .../shared/keystore/dynamodb-keystore.ts | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/nodejs/src/session-replay/recording-api/recording-service.ts b/nodejs/src/session-replay/recording-api/recording-service.ts index bf660f522aae..cdb44d1d3a91 100644 --- a/nodejs/src/session-replay/recording-api/recording-service.ts +++ b/nodejs/src/session-replay/recording-api/recording-service.ts @@ -1,4 +1,4 @@ -import { GetObjectCommand, S3Client } from '@aws-sdk/client-s3' +import { GetObjectCommand, NoSuchKey, S3Client } from '@aws-sdk/client-s3' import { ClickHouseClient } from '@clickhouse/client' import snappy from 'snappy' @@ -136,7 +136,7 @@ export class RecordingService { ) return { ok: true, data: result } } catch (error) { - if ((error as Error)?.name === 'NoSuchKey') { + if (error instanceof NoSuchKey || (error as Error)?.name === 'NoSuchKey') { logger.warn('[RecordingService] S3 object not found (NoSuchKey)', { key, teamId, diff --git a/nodejs/src/session-replay/shared/keystore/dynamodb-keystore.ts b/nodejs/src/session-replay/shared/keystore/dynamodb-keystore.ts index 00131dfa98b1..3556b6deb385 100644 --- a/nodejs/src/session-replay/shared/keystore/dynamodb-keystore.ts +++ b/nodejs/src/session-replay/shared/keystore/dynamodb-keystore.ts @@ -1,4 +1,10 @@ -import { DynamoDBClient, GetItemCommand, PutItemCommand, UpdateItemCommand } from '@aws-sdk/client-dynamodb' +import { + ConditionalCheckFailedException, + DynamoDBClient, + GetItemCommand, + PutItemCommand, + UpdateItemCommand, +} from '@aws-sdk/client-dynamodb' import { DecryptCommand, GenerateDataKeyCommand, KMSClient } from '@aws-sdk/client-kms' import sodium from 'libsodium-wrappers' @@ -59,7 +65,10 @@ export class DynamoDBKeyStore implements KeyStore { }) ) } catch (error) { - if ((error as Error)?.name === 'ConditionalCheckFailedException') { + if ( + error instanceof ConditionalCheckFailedException || + (error as Error)?.name === 'ConditionalCheckFailedException' + ) { // Key already exists — return the existing key instead of overwriting return this.getKey(sessionId, teamId) }