Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions apps/server/src/persistence/Layers/Sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,27 @@ const setup = Layer.effectDiscard(
}),
);

// `setup` depends on SqlClient, so runtime layer must be provided into `setup`.
// Keep ordering consistent with file-backed persistence (setup requires SqlClient).
const makeSqlitePersistenceLayer = (config: RuntimeSqliteLayerConfig) =>
Layer.provideMerge(setup, makeRuntimeSqliteLayer(config));

export const makeSqlitePersistenceLive = Effect.fn("makeSqlitePersistenceLive")(function* (
dbPath: string,
) {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
yield* fs.makeDirectory(path.dirname(dbPath), { recursive: true });

return Layer.provideMerge(
setup,
makeRuntimeSqliteLayer({
filename: dbPath,
spanAttributes: {
"db.name": path.basename(dbPath),
"service.name": "t3-server",
},
}),
);
}, Layer.unwrap);
return makeSqlitePersistenceLayer({
filename: dbPath,
spanAttributes: {
"db.name": path.basename(dbPath),
"service.name": "t3-server",
},
});

export const SqlitePersistenceMemory = Layer.provideMerge(
setup,
makeRuntimeSqliteLayer({ filename: ":memory:" }),
);
export const SqlitePersistenceMemory = makeSqlitePersistenceLayer({ filename: ":memory:" });
Comment on lines +50 to +58
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Read-only verification: show the affected block and confirm missing closure before Line 56.
nl -ba apps/server/src/persistence/Layers/Sqlite.ts | sed -n '41,62p'

Repository: Josh-wt/t3code

Length of output: 98


🏁 Script executed:

cat -n apps/server/src/persistence/Layers/Sqlite.ts | sed -n '40,65p'

Repository: Josh-wt/t3code

Length of output: 870


Blocker: makeSqlitePersistenceLive is not closed, causing a parse error at Line 56.

The generator function for Effect.fn("makeSqlitePersistenceLive") is missing its closing brace and the Layer.unwrap configuration. export const SqlitePersistenceMemory at line 56 cannot be parsed as a top-level statement because it remains syntactically nested inside the unclosed function.

Proposed fix
  return makeSqlitePersistenceLayer({
    filename: dbPath,
    spanAttributes: {
      "db.name": path.basename(dbPath),
      "service.name": "t3-server",
    },
  });
+}, Layer.unwrap);

 export const SqlitePersistenceMemory = makeSqlitePersistenceLayer({ filename: ":memory:" });
🧰 Tools
🪛 Biome (2.4.10)

[error] 56-56: Illegal use of an export declaration not at the top level

(parse)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/server/src/persistence/Layers/Sqlite.ts` around lines 48 - 56, The
generator for Effect.fn("makeSqlitePersistenceLive") is missing its closing
brace and the Layer.unwrap export, leaving export const SqlitePersistenceMemory
syntactically inside that function; close the Effect.fn block properly and
return/unwrap the Layer (use Layer.unwrap or the same pattern used for other
persistence layers) so the live layer definition is complete (ensure the
function name makeSqlitePersistenceLive and the Layer.unwrap call are
added/closed) and then the top-level export const SqlitePersistenceMemory can
appear after the closed block.


export const layerConfig = Layer.unwrap(
Effect.map(Effect.service(ServerConfig), ({ dbPath }) => makeSqlitePersistenceLive(dbPath)),
Expand Down