@tursodatabase/serverless 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/compat.js +14 -0
  2. package/package.json +1 -1
package/dist/compat.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Session } from './session.js';
2
+ import { AsyncLock } from './async-lock.js';
2
3
  import { DatabaseError } from './error.js';
3
4
  /**
4
5
  * libSQL-compatible error class with error codes.
@@ -15,6 +16,7 @@ export class LibsqlError extends Error {
15
16
  }
16
17
  class LibSQLClient {
17
18
  constructor(config) {
19
+ this.execLock = new AsyncLock();
18
20
  this._closed = false;
19
21
  this._defaultSafeIntegers = false;
20
22
  this.validateConfig(config);
@@ -101,6 +103,7 @@ class LibSQLClient {
101
103
  return resultSet;
102
104
  }
103
105
  async execute(stmtOrSql, args) {
106
+ await this.execLock.acquire();
104
107
  try {
105
108
  if (this._closed) {
106
109
  throw new LibsqlError("Client is closed", "CLIENT_CLOSED");
@@ -122,8 +125,12 @@ class LibSQLClient {
122
125
  }
123
126
  throw mapDatabaseError(error, "EXECUTE_ERROR");
124
127
  }
128
+ finally {
129
+ this.execLock.release();
130
+ }
125
131
  }
126
132
  async batch(stmts, mode) {
133
+ await this.execLock.acquire();
127
134
  try {
128
135
  if (this._closed) {
129
136
  throw new LibsqlError("Client is closed", "CLIENT_CLOSED");
@@ -142,6 +149,9 @@ class LibSQLClient {
142
149
  }
143
150
  throw mapDatabaseError(error, "BATCH_ERROR");
144
151
  }
152
+ finally {
153
+ this.execLock.release();
154
+ }
145
155
  }
146
156
  async migrate(stmts) {
147
157
  // For now, just call batch - in a real implementation this would disable foreign keys
@@ -151,6 +161,7 @@ class LibSQLClient {
151
161
  throw new LibsqlError("Transactions not implemented", "NOT_IMPLEMENTED");
152
162
  }
153
163
  async executeMultiple(sql) {
164
+ await this.execLock.acquire();
154
165
  try {
155
166
  if (this._closed) {
156
167
  throw new LibsqlError("Client is closed", "CLIENT_CLOSED");
@@ -163,6 +174,9 @@ class LibSQLClient {
163
174
  }
164
175
  throw mapDatabaseError(error, "EXECUTE_MULTIPLE_ERROR");
165
176
  }
177
+ finally {
178
+ this.execLock.release();
179
+ }
166
180
  }
167
181
  async sync() {
168
182
  throw new LibsqlError("Sync not supported for remote databases", "NOT_SUPPORTED");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tursodatabase/serverless",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",