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 examples/app-showcase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@objectstack/connector-slack": "workspace:*",
"@objectstack/driver-sql": "workspace:*",
"@objectstack/runtime": "workspace:*",
"@objectstack/service-datasource": "workspace:*",
"@objectstack/spec": "workspace:*"
},
"devDependencies": {
Expand Down
26 changes: 20 additions & 6 deletions examples/app-showcase/src/system/datasources/external-fixture.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

import { SqlDriver } from '@objectstack/driver-sql';
import { resolveSqliteDriver } from '@objectstack/service-datasource';

/**
* Fixture provisioning for the external-datasource federation demo
Expand All @@ -11,6 +11,14 @@ import { SqlDriver } from '@objectstack/driver-sql';
* driver — DDL allowed) so `os dev` needs no external server. It runs from the
* stack's `onEnable` hook at boot.
*
* The MANAGED driver is built via the shared `resolveSqliteDriver` step-down
* (#2229) rather than a raw `new SqlDriver({ client: 'better-sqlite3' })`: in dev
* a native `better-sqlite3` ABI/load failure (e.g. a `NODE_MODULE_VERSION`
* mismatch after a Node upgrade) steps down to wasm SQLite instead of throwing.
* Without this, an ABI mismatch here crashed the whole `onEnable` hook —
* bricking `plugin.app.<showcase>` boot even though the default datasource had
* already fallen back to wasm.
*
* **It no longer registers a driver or syncs object schemas (ADR-0062 D8).** The
* declared `external` datasource (see `showcase-external.datasource.ts`) now
* AUTO-CONNECTS: at boot the runtime's `DatasourceConnectionService` builds the
Expand Down Expand Up @@ -71,11 +79,17 @@ interface OnEnableContext {
* datasource auto-connects at boot (ADR-0062 D1/D8).
*/
export async function setupShowcaseExternalDatasource(ctx: OnEnableContext): Promise<void> {
const fixture = new SqlDriver({
client: 'better-sqlite3',
connection: { filename: EXTERNAL_DB_FILE },
useNullAsDefault: true,
}) as unknown as {
// Build the managed provisioning driver through the shared native → wasm →
// in-memory step-down (#2229). In dev, a native better-sqlite3 ABI/load
// failure steps down to wasm SQLite (real SQL + on-disk persistence) so the
// fixture — and therefore `onEnable` / app-plugin boot — never crashes on a
// `NODE_MODULE_VERSION` mismatch; in production it returns the native driver
// unprobed (fail-closed), preserving the historical behavior.
const resolved = await resolveSqliteDriver({
filename: EXTERNAL_DB_FILE,
warn: (m: string) => ctx.logger?.warn?.(m),
});
const fixture = resolved.driver as unknown as {
name: string;
connect: () => Promise<void>;
disconnect: () => Promise<void>;
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.