{"record":{"id":"7bdb25a52cf28ba9","repo":"tursodatabase/turso","slug":"sync-is-disabled-as-database-was-opened-without-sy","errorCode":null,"errorMessage":"sync is disabled as database was opened without sync support","messagePattern":"sync is disabled as database was opened without sync support","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"bindings/javascript/sync/packages/native/promise.ts","lineNumber":175,"sourceCode":"     */\n    override async connect() {\n        if (this.connected) {\n            return;\n        } else if (this.#engine == null) {\n            await super.connect();\n        } else {\n            await run(this.#runner!, this.#engine.connect());\n        }\n        this.connected = true;\n    }\n    /**\n     * pull new changes from the remote database\n     * if {@link DatabaseOpts.longPollTimeoutMs} is set - then server will hold the connection open until either new changes will appear in the database or timeout occurs.\n     * @returns true if new changes were pulled from the remote\n     */\n    async pull() {\n        if (this.#engine == null) {\n            throw new Error(\"sync is disabled as database was opened without sync support\")\n        }\n        const changes = await this.#guards!.wait(async () => await run(this.#runner!, this.#engine.wait()));\n        if (changes.empty()) {\n            return false;\n        }\n        await this.#guards!.apply(async () => await run(this.#runner!, this.#engine.apply(changes)));\n        return true;\n    }\n    /**\n     * push new local changes to the remote database\n     * if {@link DatabaseOpts.transform} is set - then provided callback will be called for every mutation before sending it to the remote\n     */\n    async push() {\n        if (this.#engine == null) {\n            throw new Error(\"sync is disabled as database was opened without sync support\")\n        }\n        await this.#guards!.push(async () => await run(this.#runner!, this.#engine.push()));\n    }","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/tursodatabase/turso/blob/bad083fafbefdeae9a42ec19bdaaad8918dcf411/bindings/javascript/sync/packages/native/promise.ts#L157-L193","documentation":"The sync-flavored Database only builds a SyncEngine when constructed with a URL; when opts.url is null it wraps a plain local database and sets #engine = null. pull() guards on that engine and throws this error, telling you the instance has no sync capability. pull() (long-poll wait + apply) simply does not exist for local-only databases.","triggerScenarios":"new Database({ path: 'local.db' }) from the sync package (no url option) followed by db.pull(); a url option that is undefined because the env var was missing; shared factory code that sometimes passes a URL and sometimes does not.","commonSituations":"One code path used for both local-only and synced deployments where the sync URL env var is absent locally or in CI; optional sync feature toggled by presence of a URL; tests constructing the DB without a remote.","solutions":["Pass url (and usually authToken) in DatabaseOpts to enable the sync engine: new Database({ path, url: 'libsql://...', authToken }).","If this instance is intentionally local-only, do not call pull() — use the plain native package instead.","Guard calls with a sync-enabled flag captured at construction time."],"exampleFix":"// before\nconst db = new Database({ path: 'local.db' }); // no url -> engine disabled\nawait db.pull(); // throws\n\n// after\nconst db = new Database({ path: 'local.db', url: 'libsql://my-db.turso.io', authToken });\nawait db.connect();\nawait db.pull();","handlingStrategy":"type-guard","validationCode":"// capture sync capability at construction time\nconst syncEnabled = opts.url != null;\nconst db = new Database(opts);\nif (syncEnabled) { await db.connect(); await db.pull(); }","typeGuard":"function isSyncCapable(db: Database): boolean {\n  // engine is private; rely on your own construction flag instead\n  return db instanceof Database && (db as any).pull === 'function' && syncEnabledFlag(db);\n}","tryCatchPattern":null,"preventionTips":["Centralize Database construction so the url option is always set when sync is expected.","Fail fast at startup if a required sync URL env var is missing.","Only call pull/push/checkpoint/stats on instances built with a URL."],"tags":["sync","pull","engine-disabled","configuration","javascript"],"backgroundTag":"sync-not-enabled","analyzedSha":"bad083fafbefdeae9a42ec19bdaaad8918dcf411","analyzedAt":"2026-08-16T23:12:11.798Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}