From 88b03cb5c24a3f205ef50663eb70d5bc7230ec39 Mon Sep 17 00:00:00 2001 From: Tudor Zaharia Date: Wed, 6 May 2026 14:48:35 +0200 Subject: [PATCH 01/11] website changes for electric.ax --- README.md | 4 ++-- docs/.vitepress/config.mts | 6 +++--- docs/docs/about.md | 2 +- docs/docs/sync.md | 10 +++++----- docs/index.md | 2 +- packages/pglite-react/test/hooks.test.tsx | 4 ++-- packages/pglite-sync/README.md | 4 ++-- packages/pglite-sync/package.json | 2 +- packages/pglite-sync/src/index.ts | 2 +- packages/pglite/README.md | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index e8d3e20a5..c80cef47b 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ - ElectricSQL logo @@ -15,7 +15,7 @@

- PGlite - the WASM build of Postgres from ElectricSQL.
+ PGlite - the WASM build of Postgres from Electric.
Build reactive, realtime, local-first apps directly on Postgres.

diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 9c01e1a70..2f8ece018 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -80,7 +80,7 @@ export default defineConfig({ { text: 'About', link: '/docs/about' }, { text: 'Docs', link: '/docs/' }, { text: 'REPL', link: '/repl/' }, - { text: 'ElectricSQL', link: 'https://www.electric-sql.com' }, + { text: 'Electric', link: 'https://www.electric.ax' }, { text: 'GitHub', link: 'https://github.com/electric-sql/pglite', @@ -119,7 +119,7 @@ export default defineConfig({ { text: 'Multi-tab Worker', link: '/docs/multi-tab-worker' }, { text: 'REPL Component', link: '/docs/repl' }, { text: 'ORMs & Query Builders', link: '/docs/orm-support' }, - { text: 'Sync using ElectricSQL', link: '/docs/sync' }, + { text: 'Sync using Postgres Sync', link: '/docs/sync' }, { text: 'PGlite Socket', link: '/docs/pglite-socket' }, { text: 'PGlite tools', @@ -159,7 +159,7 @@ export default defineConfig({ footer: { message: 'Dual-licensed under Apache 2.0 and the PostgreSQL License', - copyright: '© ElectricSQL', + copyright: '© Electric', }, search: { provider: 'local', diff --git a/docs/docs/about.md b/docs/docs/about.md index 74f8a0b10..f96de9687 100644 --- a/docs/docs/about.md +++ b/docs/docs/about.md @@ -16,7 +16,7 @@ It can be used as an ephemeral in-memory database, or with persistence either to Unlike previous "Postgres in the browser" projects, PGlite does not use a Linux virtual machine - it is simply Postgres in WASM. -It's being developed by [ElectricSQL](https://electric-sql.com/) for our use case of embedding into applications, either locally or at the edge, allowing users to sync a subset of their server-side Postgres database. +It's being developed by [Electric](https://electric.ax/) for our use case of embedding into applications, either locally or at the edge, allowing users to sync a subset of their server-side Postgres database. However, there are many more use cases for PGlite beyond its use as an embedded application database: diff --git a/docs/docs/sync.md b/docs/docs/sync.md index d7e3aaadf..298901eea 100644 --- a/docs/docs/sync.md +++ b/docs/docs/sync.md @@ -1,6 +1,6 @@ -# Sync using ElectricSQL +# Sync using Electric -At [ElectricSQL](https://electric-sql.com/) we are building a sync engine to enable realtime partial replication from Postgres to any other datastore, be it a JavaScript framework state store in a webapp, a database at the edge, or an embedded database in the mobile application. +At [Electric](https://electric.ax/) we are building a sync engine to enable realtime partial replication from Postgres to any other datastore, be it a JavaScript framework state store in a webapp, a database at the edge, or an embedded database in the mobile application. To accompany Electric, we are developing a sync extension for PGlite that will enable you to synchronise a remote Postgres with PGlite. @@ -113,12 +113,12 @@ The `electricSync` plugin can be given some configuration options to allow custo ## syncShapeToTable API -The `syncShapeToTable` is a relatively thin wrapper around the Electric [ShapeStream API](https://next.electric-sql.com/api/clients/typescript#shapestream) designed to do the minimal required to sync a shape _into_ a table. +The `syncShapeToTable` is a relatively thin wrapper around the Electric [ShapeStream API](https://electric.ax/docs/api/clients/typescript#shapestream) designed to do the minimal required to sync a shape _into_ a table. It takes the following options as an object: - `shape: ShapeStreamOptions`
- The shape stream specification to sync, described by the Electric [ShapeStream API](https://electric-sql.com/docs/api/clients/typescript#shapestream) options, see the [ShapeStream API](https://electric-sql.com/docs/api/clients/typescript#options) for more details. + The shape stream specification to sync, described by the Electric [ShapeStream API](https://electric.ax/docs/api/clients/typescript#shapestream) options, see the [ShapeStream API](https://electric.ax/docs/api/clients/typescript#options) for more details. - `table: string`
The name of the table to sync into. @@ -169,7 +169,7 @@ The returned `shape` object from the `syncShapeToTable` call has the following m Unsubscribe from the shape. Note that this does not clear the state that has been synced into the table. - `stream: ShapeStream`
- The underlying `ShapeStream` instance, see the [ShapeStream API](https://electric-sql.com/docs/api/clients/typescript#shapestream) for more details. + The underlying `ShapeStream` instance, see the [ShapeStream API](https://electric.ax/docs/api/clients/typescript#shapestream) for more details. ## syncShapesToTables API diff --git a/docs/index.md b/docs/index.md index 4abcf146e..c5550f982 100644 --- a/docs/index.md +++ b/docs/index.md @@ -56,7 +56,7 @@ async function renderGitHub() { if (!countEl) { countEl = document.createElement('span') countEl.classList.add('count') - countEl.innerText = `(${toShortDecimal(initialStarCount)})`; + countEl.innerText = `( ☆ ${toShortDecimal(initialStarCount)})`; const icon = document.createElement('span') icon.classList.add('vpi-social-github') diff --git a/packages/pglite-react/test/hooks.test.tsx b/packages/pglite-react/test/hooks.test.tsx index 6d51e0f83..75dcc0e13 100644 --- a/packages/pglite-react/test/hooks.test.tsx +++ b/packages/pglite-react/test/hooks.test.tsx @@ -412,11 +412,11 @@ function testLiveQuery(queryHook: 'useLiveQuery' | 'useLiveIncrementalQuery') { ) // Trigger an update await db.exec( - `INSERT INTO pattern_matching (statement) VALUES ('ElectricSQL + pglite = <3');`, + `INSERT INTO pattern_matching (statement) VALUES ('Electric + pglite = <3');`, ) await waitFor(() => expect(result.current?.rows[0].statement).toBe( - 'ElectricSQL + pglite = <3', + 'Electric + pglite = <3', ), ) }) diff --git a/packages/pglite-sync/README.md b/packages/pglite-sync/README.md index 5f1f0a323..f6116d9ec 100644 --- a/packages/pglite-sync/README.md +++ b/packages/pglite-sync/README.md @@ -1,6 +1,6 @@ -# PGlite ElectricSQL Sync Plugin +# PGlite Postgres Sync Plugin -A [sync plugin](https://pglite.dev/docs/sync) for [PGlite](https://pglite.dev/) using [ElectricSQL](https://electric-sql.com/). Full documentation is available at [pglite.dev/docs/sync](https://pglite.dev/docs/sync). +A [sync plugin](https://pglite.dev/docs/sync) for [PGlite](https://pglite.dev/) using [Electric](https://electric.ax/). Full documentation is available at [pglite.dev/docs/sync](https://pglite.dev/docs/sync). To install: diff --git a/packages/pglite-sync/package.json b/packages/pglite-sync/package.json index f6616982d..a7a72e7df 100644 --- a/packages/pglite-sync/package.json +++ b/packages/pglite-sync/package.json @@ -1,7 +1,7 @@ { "name": "@electric-sql/pglite-sync", "version": "0.5.5", - "description": "ElectricSQL Sync for PGlite", + "description": "Postgres Sync for PGlite", "type": "module", "private": false, "publishConfig": { diff --git a/packages/pglite-sync/src/index.ts b/packages/pglite-sync/src/index.ts index 641dae7e5..97dfe2b78 100644 --- a/packages/pglite-sync/src/index.ts +++ b/packages/pglite-sync/src/index.ts @@ -514,7 +514,7 @@ export type PGliteWithSync = PGliteInterface & { export function electricSync(options?: ElectricSyncOptions) { return { - name: 'ElectricSQL Sync', + name: 'Postgres Sync', setup: async (pg: PGliteInterface) => { const { namespaceObj, close } = await createPlugin(pg, options) return { diff --git a/packages/pglite/README.md b/packages/pglite/README.md index 2618e95d2..d3e09b44b 100644 --- a/packages/pglite/README.md +++ b/packages/pglite/README.md @@ -7,7 +7,7 @@ - ElectricSQL logo @@ -15,7 +15,7 @@

- PGlite - the WASM build of Postgres from ElectricSQL.
+ PGlite - the WASM build of Postgres from Electric.
Build reactive, realtime, local-first apps directly on Postgres.

From 2bad885e8515f9834531a0490ecbc1411cac1130 Mon Sep 17 00:00:00 2001 From: Tudor Zaharia Date: Wed, 6 May 2026 15:24:13 +0200 Subject: [PATCH 02/11] restore process.exitCode --- packages/pglite/src/pglite.ts | 16 ++++++++++++++++ packages/pglite/tests/basic.test.ts | 14 ++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/packages/pglite/src/pglite.ts b/packages/pglite/src/pglite.ts index 297efd2b8..564911f43 100644 --- a/packages/pglite/src/pglite.ts +++ b/packages/pglite/src/pglite.ts @@ -256,6 +256,14 @@ export class PGlite * @returns A promise that resolves when the database is ready */ async #init(options: PGliteOptions) { + + // PGlite modifies process.exitCode when it does exit(XX) + // we need to restore the previous value + let prevExitCode = undefined + if (typeof globalThis.process !== 'undefined') { + prevExitCode = process.exitCode + } + if (options.fs) { this.fs = options.fs } else { @@ -567,6 +575,10 @@ export class PGlite await initFn() } } + + if (typeof globalThis.process !== 'undefined' ) { + process.exitCode = prevExitCode + } } #onRuntimeInitialized(mod: PostgresMod) { @@ -828,6 +840,9 @@ export class PGlite return result } + // store current process exit code + const prevExitCode = process.exitCode + // execute the message try { // a single message might contain multiple batched queries @@ -858,6 +873,7 @@ export class PGlite } finally { mod._PostgresSendReadyForQueryIfNecessary() mod._pgl_pq_flush() + process.exitCode = prevExitCode } this.#outputData = [] diff --git a/packages/pglite/tests/basic.test.ts b/packages/pglite/tests/basic.test.ts index db88ebe38..b845b4f1f 100644 --- a/packages/pglite/tests/basic.test.ts +++ b/packages/pglite/tests/basic.test.ts @@ -701,5 +701,19 @@ await testEsmCjsAndDTC(async (importType) => { ) expect(databaseAndRole[0].rows[0].setting).toEqual(dateTime) }) + + it('restores process.exitCode', async () => { + const origExitCode = process.exitCode + const db = await PGlite.create() + expect(process.exitCode).toEqual(origExitCode) + + await db.exec(` + CREATE TABLE IF NOT EXISTS test ( + id SERIAL PRIMARY KEY, + name TEXT + );`) + + expect(process.exitCode).toEqual(origExitCode) + }) }) }) From 0cebeb8730f597d4722732dd8356f787414dd225 Mon Sep 17 00:00:00 2001 From: Tudor Zaharia Date: Wed, 6 May 2026 15:24:30 +0200 Subject: [PATCH 03/11] style --- packages/pglite/src/pglite.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/pglite/src/pglite.ts b/packages/pglite/src/pglite.ts index 564911f43..b9eda492f 100644 --- a/packages/pglite/src/pglite.ts +++ b/packages/pglite/src/pglite.ts @@ -256,7 +256,6 @@ export class PGlite * @returns A promise that resolves when the database is ready */ async #init(options: PGliteOptions) { - // PGlite modifies process.exitCode when it does exit(XX) // we need to restore the previous value let prevExitCode = undefined @@ -576,7 +575,7 @@ export class PGlite } } - if (typeof globalThis.process !== 'undefined' ) { + if (typeof globalThis.process !== 'undefined') { process.exitCode = prevExitCode } } From 7c4132ae1ddb1f85a3183f7d3c38b5fb86167e4b Mon Sep 17 00:00:00 2001 From: Tudor Zaharia Date: Wed, 6 May 2026 15:26:00 +0200 Subject: [PATCH 04/11] changeset --- .changeset/slimy-buckets-wink.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/slimy-buckets-wink.md diff --git a/.changeset/slimy-buckets-wink.md b/.changeset/slimy-buckets-wink.md new file mode 100644 index 000000000..d5654d1b0 --- /dev/null +++ b/.changeset/slimy-buckets-wink.md @@ -0,0 +1,5 @@ +--- +'@electric-sql/pglite': patch +--- + +Restore process.exitCode From e19f1f88fe422dfcb43889f78b48fb260593ac93 Mon Sep 17 00:00:00 2001 From: Tudor Zaharia Date: Thu, 7 May 2026 10:44:06 +0200 Subject: [PATCH 05/11] try fix process in web --- packages/pglite/src/pglite.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/pglite/src/pglite.ts b/packages/pglite/src/pglite.ts index b9eda492f..4bd597eec 100644 --- a/packages/pglite/src/pglite.ts +++ b/packages/pglite/src/pglite.ts @@ -259,7 +259,7 @@ export class PGlite // PGlite modifies process.exitCode when it does exit(XX) // we need to restore the previous value let prevExitCode = undefined - if (typeof globalThis.process !== 'undefined') { + if (typeof globalThis.process !== 'undefined' && process) { prevExitCode = process.exitCode } @@ -575,7 +575,7 @@ export class PGlite } } - if (typeof globalThis.process !== 'undefined') { + if (typeof globalThis.process !== 'undefined' && process) { process.exitCode = prevExitCode } } From 2f0ca789b743048ef7022145d76832620c297f5f Mon Sep 17 00:00:00 2001 From: Tudor Zaharia Date: Thu, 7 May 2026 11:10:21 +0200 Subject: [PATCH 06/11] different approach of checking process existance --- packages/pglite/src/pglite.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/pglite/src/pglite.ts b/packages/pglite/src/pglite.ts index 4bd597eec..18e7694e4 100644 --- a/packages/pglite/src/pglite.ts +++ b/packages/pglite/src/pglite.ts @@ -259,7 +259,7 @@ export class PGlite // PGlite modifies process.exitCode when it does exit(XX) // we need to restore the previous value let prevExitCode = undefined - if (typeof globalThis.process !== 'undefined' && process) { + if (globalThis.process?.env) { prevExitCode = process.exitCode } @@ -575,7 +575,7 @@ export class PGlite } } - if (typeof globalThis.process !== 'undefined' && process) { + if (globalThis.process?.env) { process.exitCode = prevExitCode } } From 56d223f94d94aa1f286cb55d7002a3cbe5960dd2 Mon Sep 17 00:00:00 2001 From: Tudor Zaharia Date: Thu, 7 May 2026 11:44:54 +0200 Subject: [PATCH 07/11] try a different approach --- packages/pglite/src/pglite.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/pglite/src/pglite.ts b/packages/pglite/src/pglite.ts index 18e7694e4..4ea5d306d 100644 --- a/packages/pglite/src/pglite.ts +++ b/packages/pglite/src/pglite.ts @@ -259,7 +259,7 @@ export class PGlite // PGlite modifies process.exitCode when it does exit(XX) // we need to restore the previous value let prevExitCode = undefined - if (globalThis.process?.env) { + if (pglUtils.IN_NODE) { prevExitCode = process.exitCode } @@ -575,7 +575,7 @@ export class PGlite } } - if (globalThis.process?.env) { + if (pglUtils.IN_NODE) { process.exitCode = prevExitCode } } From 0ee83415018c247266db05d6d238d7adfec315a0 Mon Sep 17 00:00:00 2001 From: Tudor Zaharia Date: Thu, 7 May 2026 12:15:13 +0200 Subject: [PATCH 08/11] try again --- packages/pglite/src/pglite.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/pglite/src/pglite.ts b/packages/pglite/src/pglite.ts index 4ea5d306d..1e2a035c8 100644 --- a/packages/pglite/src/pglite.ts +++ b/packages/pglite/src/pglite.ts @@ -872,7 +872,9 @@ export class PGlite } finally { mod._PostgresSendReadyForQueryIfNecessary() mod._pgl_pq_flush() - process.exitCode = prevExitCode + if (pglUtils.IN_NODE) { + process.exitCode = prevExitCode + } } this.#outputData = [] From 0387fae71f24499cc057b4f141b2962e86a3f079 Mon Sep 17 00:00:00 2001 From: Tudor Zaharia Date: Thu, 7 May 2026 12:35:52 +0200 Subject: [PATCH 09/11] fix --- packages/pglite/src/pglite.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/pglite/src/pglite.ts b/packages/pglite/src/pglite.ts index 1e2a035c8..6f51c7a19 100644 --- a/packages/pglite/src/pglite.ts +++ b/packages/pglite/src/pglite.ts @@ -259,7 +259,7 @@ export class PGlite // PGlite modifies process.exitCode when it does exit(XX) // we need to restore the previous value let prevExitCode = undefined - if (pglUtils.IN_NODE) { + if (globalThis.process?.env) { prevExitCode = process.exitCode } @@ -575,7 +575,7 @@ export class PGlite } } - if (pglUtils.IN_NODE) { + if (globalThis.process?.env) { process.exitCode = prevExitCode } } @@ -839,8 +839,11 @@ export class PGlite return result } - // store current process exit code - const prevExitCode = process.exitCode + let prevExitCode = undefined + if (globalThis.process?.env) { + // store current process exit code + prevExitCode = process.exitCode + } // execute the message try { @@ -872,7 +875,7 @@ export class PGlite } finally { mod._PostgresSendReadyForQueryIfNecessary() mod._pgl_pq_flush() - if (pglUtils.IN_NODE) { + if (globalThis.process?.env) { process.exitCode = prevExitCode } } From a6ccd9b36937d51195b63a5e5c33d58017526cd2 Mon Sep 17 00:00:00 2001 From: Tudor Zaharia Date: Mon, 18 May 2026 08:45:26 +0200 Subject: [PATCH 10/11] update submodule --- postgres-pglite | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres-pglite b/postgres-pglite index 01792c31a..7d5da8206 160000 --- a/postgres-pglite +++ b/postgres-pglite @@ -1 +1 @@ -Subproject commit 01792c31a62b7045eb22e93d7dad022bb64b1184 +Subproject commit 7d5da82062a633eb2ca8e007a5ac9951f3981726 From 5442a288d639653579b5372f8131a8956c8d4745 Mon Sep 17 00:00:00 2001 From: Tudor Zaharia Date: Thu, 21 May 2026 11:57:50 +0200 Subject: [PATCH 11/11] restore exit code changeset --- .changeset/witty-clocks-kneel.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/witty-clocks-kneel.md diff --git a/.changeset/witty-clocks-kneel.md b/.changeset/witty-clocks-kneel.md new file mode 100644 index 000000000..746d4cffe --- /dev/null +++ b/.changeset/witty-clocks-kneel.md @@ -0,0 +1,5 @@ +--- +'@electric-sql/pglite': patch +--- + +restore exit code