Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixed an issue where `--import` path was incorrectly resolved for the Data Connect emulator. (#8219)
4 changes: 4 additions & 0 deletions src/emulator/dataconnect/pgliteServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// They are only available as ESM, and if we import them normally,
// our tsconfig will convert them to requires, which will cause errors
// during module resolution.
const { dynamicImport } = require(true && "../../dynamicImport");

Check warning on line 8 in src/emulator/dataconnect/pgliteServer.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

Check warning on line 8 in src/emulator/dataconnect/pgliteServer.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Require statement not part of import statement
import * as net from "node:net";
import * as fs from "fs";

Expand Down Expand Up @@ -41,10 +41,10 @@
public db: PGlite | undefined = undefined;
private server: net.Server | undefined = undefined;

public async createPGServer(host: string = "127.0.0.1", port: number): Promise<net.Server> {

Check warning on line 44 in src/emulator/dataconnect/pgliteServer.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Type string trivially inferred from a string literal, remove type annotation
const getDb = this.getDb.bind(this);

const server = net.createServer(async (socket) => {

Check warning on line 47 in src/emulator/dataconnect/pgliteServer.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Promise returned in function argument where a void return was expected
const connection: PostgresConnection = await fromNodeSocket(socket, {
serverVersion: "16.3 (PGlite 0.2.0)",
auth: { method: "trust" },
Expand All @@ -63,11 +63,11 @@
const result = await db.execProtocolRaw(data);
// Extended query patch removes the extra Ready for Query messages that
// pglite wrongly sends.
return extendedQueryPatch.filterResponse(data, result);

Check warning on line 66 in src/emulator/dataconnect/pgliteServer.ts

View workflow job for this annotation

GitHub Actions / lint (20)

'extendedQueryPatch' was used before it was defined
},
});

const extendedQueryPatch: PGliteExtendedQueryPatch = new PGliteExtendedQueryPatch(connection);

Check warning on line 70 in src/emulator/dataconnect/pgliteServer.ts

View workflow job for this annotation

GitHub Actions / lint (20)

'PGliteExtendedQueryPatch' was used before it was defined

socket.on("end", () => {
logger.debug("Postgres client disconnected");
Expand All @@ -89,10 +89,14 @@

async getDb(): Promise<PGlite> {
if (!this.db) {
// First, ensure that the data directory exists - PGLite tries to do this but doesn't do so recursively
if (this.dataDirectory && !fs.existsSync(this.dataDirectory)) {
fs.mkdirSync(this.dataDirectory, { recursive: true });
}
// Not all schemas will need vector installed, but we don't have an good way
// to swap extensions after starting PGLite, so we always include it.
const vector = (await dynamicImport("@electric-sql/pglite/vector")).vector;

Check warning on line 98 in src/emulator/dataconnect/pgliteServer.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

Check warning on line 98 in src/emulator/dataconnect/pgliteServer.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .vector on an `any` value

Check warning on line 98 in src/emulator/dataconnect/pgliteServer.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe call of an `any` typed value
const uuidOssp = (await dynamicImport("@electric-sql/pglite/contrib/uuid_ossp")).uuid_ossp;

Check warning on line 99 in src/emulator/dataconnect/pgliteServer.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
const pgliteArgs: PGliteOptions = {
debug: this.debug,
extensions: {
Expand Down
3 changes: 1 addition & 2 deletions src/emulator/dataconnectEmulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export class DataConnectEmulator implements EmulatorInstance {
let resolvedConfigDir;
try {
resolvedConfigDir = this.args.config.path(this.args.configDir);

const info = await DataConnectEmulator.build({ configDir: resolvedConfigDir });
if (requiresVector(info.metadata)) {
if (Constants.isDemoProject(this.args.projectId)) {
Expand Down Expand Up @@ -125,7 +124,7 @@ export class DataConnectEmulator implements EmulatorInstance {
dataDirectory = this.args.config.path(dataDirectory);
}
const postgresDumpPath = this.args.importPath
? path.join(this.args.config.path(this.args.importPath), "postgres.tar.gz")
? path.join(this.args.importPath, "postgres.tar.gz")
: undefined;
this.postgresServer = new PostgresServer({
dataDirectory,
Expand Down
Loading