@libsql/hrana-client
Advanced tools
Comparing version 0.5.0-pre.1 to 0.5.0-pre.2
@@ -31,2 +31,3 @@ "use strict"; | ||
#closing; | ||
#closeQueued; | ||
#closed; | ||
@@ -45,2 +46,3 @@ #sqlIdAlloc; | ||
this.#closing = false; | ||
this.#closeQueued = false; | ||
this.#closed = undefined; | ||
@@ -164,9 +166,10 @@ this.#sqlIdAlloc = new id_alloc_js_1.IdAlloc(); | ||
} | ||
if (this.#baton !== undefined || this.#flushing) { | ||
if ((this.#baton !== undefined || this.#flushing) && !this.#closeQueued) { | ||
this.#queue.push({ | ||
type: "pipeline", | ||
request: { type: "close" }, | ||
responseCallback() { }, | ||
errorCallback() { }, | ||
responseCallback: () => undefined, | ||
errorCallback: () => undefined, | ||
}); | ||
this.#closeQueued = true; | ||
(0, queue_microtask_js_1.queueMicrotask)(() => this.#flushQueue()); | ||
@@ -212,2 +215,12 @@ } | ||
} | ||
else if (entry === undefined && this.#closing && !this.#closeQueued) { | ||
pipeline.push({ | ||
type: "pipeline", | ||
request: { type: "close" }, | ||
responseCallback: () => undefined, | ||
errorCallback: () => undefined, | ||
}); | ||
this.#closeQueued = true; | ||
break; | ||
} | ||
else { | ||
@@ -214,0 +227,0 @@ break; |
@@ -91,5 +91,9 @@ "use strict"; | ||
const protocol = this.#socket.protocol; | ||
if (protocol === "" || protocol === undefined) { | ||
// TODO: `protocol === undefined` is a workaround for Miniflare 2, which does not support the | ||
// `protocol` property on a WebSocket | ||
if (protocol === undefined) { | ||
this.#setClosed(new errors_js_1.ClientError("The `WebSocket.protocol` property is undefined. This most likely means that the WebSocket " + | ||
"implementation provided by the environment is broken. If you are using Miniflare 2, " + | ||
"please update to Miniflare 3, which fixes this problem.")); | ||
return; | ||
} | ||
else if (protocol === "") { | ||
this.#subprotocol = { version: 1, encoding: "json" }; | ||
@@ -96,0 +100,0 @@ } |
@@ -28,2 +28,3 @@ import { Request, Headers } from "@libsql/isomorphic-fetch"; | ||
#closing; | ||
#closeQueued; | ||
#closed; | ||
@@ -42,2 +43,3 @@ #sqlIdAlloc; | ||
this.#closing = false; | ||
this.#closeQueued = false; | ||
this.#closed = undefined; | ||
@@ -161,9 +163,10 @@ this.#sqlIdAlloc = new IdAlloc(); | ||
} | ||
if (this.#baton !== undefined || this.#flushing) { | ||
if ((this.#baton !== undefined || this.#flushing) && !this.#closeQueued) { | ||
this.#queue.push({ | ||
type: "pipeline", | ||
request: { type: "close" }, | ||
responseCallback() { }, | ||
errorCallback() { }, | ||
responseCallback: () => undefined, | ||
errorCallback: () => undefined, | ||
}); | ||
this.#closeQueued = true; | ||
queueMicrotask(() => this.#flushQueue()); | ||
@@ -209,2 +212,12 @@ } | ||
} | ||
else if (entry === undefined && this.#closing && !this.#closeQueued) { | ||
pipeline.push({ | ||
type: "pipeline", | ||
request: { type: "close" }, | ||
responseCallback: () => undefined, | ||
errorCallback: () => undefined, | ||
}); | ||
this.#closeQueued = true; | ||
break; | ||
} | ||
else { | ||
@@ -211,0 +224,0 @@ break; |
@@ -88,5 +88,9 @@ import { Client } from "../client.js"; | ||
const protocol = this.#socket.protocol; | ||
if (protocol === "" || protocol === undefined) { | ||
// TODO: `protocol === undefined` is a workaround for Miniflare 2, which does not support the | ||
// `protocol` property on a WebSocket | ||
if (protocol === undefined) { | ||
this.#setClosed(new ClientError("The `WebSocket.protocol` property is undefined. This most likely means that the WebSocket " + | ||
"implementation provided by the environment is broken. If you are using Miniflare 2, " + | ||
"please update to Miniflare 3, which fixes this problem.")); | ||
return; | ||
} | ||
else if (protocol === "") { | ||
this.#subprotocol = { version: 1, encoding: "json" }; | ||
@@ -93,0 +97,0 @@ } |
{ | ||
"name": "@libsql/hrana-client", | ||
"version": "0.5.0-pre.1", | ||
"version": "0.5.0-pre.2", | ||
"keywords": [ | ||
@@ -5,0 +5,0 @@ "hrana", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
303815
8493