Skip to content

Commit 4e79aeb

Browse files
committed
Moved ensure created inside try catch block
1 parent 20eb16c commit 4e79aeb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/packages/emmett-sqlite/src/eventStore/SQLiteEventStore.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ export const getSQLiteEventStore = (
162162
db = createConnection();
163163
}
164164

165-
await ensureSchemaExists();
166165
let stream;
167166
try {
167+
await ensureSchemaExists();
168168
stream = await readStream<EventType>(db, streamName, options);
169169
} catch (err: Error) {
170170
closeConnection();
@@ -185,15 +185,17 @@ export const getSQLiteEventStore = (
185185
db = createConnection();
186186
}
187187

188-
await ensureSchemaExists();
189188
// TODO: This has to be smarter when we introduce urn-based resolution
190189
const [firstPart, ...rest] = streamName.split('-');
191190

192191
const streamType =
193192
firstPart && rest.length > 0 ? firstPart : 'emt:unknown';
194193

195194
let appendResult;
195+
196196
try {
197+
await ensureSchemaExists();
198+
197199
appendResult = await appendToStream(
198200
db,
199201
streamName,

0 commit comments

Comments
 (0)