Skip to content

Commit

Permalink
fix(developer): try catch the redis creation
Browse files Browse the repository at this point in the history
  • Loading branch information
steveoh committed May 8, 2024
1 parent 62f3e20 commit 6acb3f9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/developer/functions/https/keys.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { getFirestore } from 'firebase-admin/firestore';
import { debug } from 'firebase-functions/logger';
import { debug, error } from 'firebase-functions/logger';
import { Redis } from 'ioredis';
import { safelyInitializeApp } from '../firebase.js';
import { minimalKeyConversion } from './converters.js';

safelyInitializeApp();
const db = getFirestore();
const empty = [];
const redis = new Redis(process.env.REDIS_HOST);

let redis = {};
try {
redis = new Redis(process.env.REDIS_HOST);
} catch (ex) {
error(error);
}
/**
* A function that returns the keys for a given user.
* @param {string} uid - the id of the user to get keys for
Expand Down Expand Up @@ -38,7 +42,6 @@ export const getKeys = async (uid) => {
debug('getting key counts for', keyNames);

try {

let counts = await redis.mget(...keyNames);

counts.forEach((count, index) => {
Expand Down

0 comments on commit 6acb3f9

Please sign in to comment.