Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(recording-api): fix aws error handling (#64376)

Zach Brown5ed294fb288f
diff --git a/nodejs/src/session-replay/recording-api/recording-service.ts b/nodejs/src/session-replay/recording-api/recording-service.ts
index 74da08c4e945..cdb44d1d3a91 100644
--- a/nodejs/src/session-replay/recording-api/recording-service.ts
+++ b/nodejs/src/session-replay/recording-api/recording-service.ts
@@ -136,7 +136,7 @@ export class RecordingService {
)
return { ok: true, data: result }
} catch (error) {
- if (error instanceof 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 f2b75e7c4d75..3556b6deb385 100644
--- a/nodejs/src/session-replay/shared/keystore/dynamodb-keystore.ts
+++ b/nodejs/src/session-replay/shared/keystore/dynamodb-keystore.ts
@@ -65,7 +65,10 @@ export class DynamoDBKeyStore implements KeyStore {
})
)
} catch (error) {
- if (error instanceof 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)
}