Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): SQLite writes no longer block the event loop #30067

Closedadvaitpaliwal(GitHub profile, opens in a new tab)wants to merge 7 commits intomain fromrefs/pull/30067/headopened View on GitHub

Showing 5 changed files with 34 additions and 89 deletions (loading 2).

x
0 of 5 viewed, 5 left
31 additions and 35 deletionsapps/server/src/orchestration-v2/FoundationPersistence.test.tsModified
View file
@@ -1,4 +1,3 @@
-import * as NodeSqlite from "node:sqlite";
import * as NodeServices from "@effect/platform-node/NodeServices";
import { assert, it } from "@effect/vitest";
import {
@@ -191,47 +190,44 @@
const path = yield* Path.Path;
const filename = path.join(yield* fs.makeTempDirectoryScoped(), "fixture.sqlite");
yield* Effect.gen(function* () {
- const sql = yield* SqlClient.SqlClient;
yield* seedCompaction();
- // Establish the reader before recording main-thread statements.
- yield* sql`SELECT 1`.pipe(NodeSqliteClient.readOnly);
- const reads: string[] = [];
- const writes: string[] = [];
- const all = NodeSqlite.StatementSync.prototype.all;
- const run = NodeSqlite.StatementSync.prototype.run;
- yield* Effect.acquireRelease(
- Effect.sync(() => {
- const readSpy = vi
- .spyOn(NodeSqlite.StatementSync.prototype, "all")
- .mockImplementation(function (this: NodeSqlite.StatementSync, ...params) {
- reads.push(this.sourceSQL);
- return all.apply(this, params);
- });
- const writeSpy = vi
- .spyOn(NodeSqlite.StatementSync.prototype, "run")
- .mockImplementation(function (this: NodeSqlite.StatementSync, ...params) {
- writes.push(this.sourceSQL);
- return run.apply(this, params);