Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@embracesql/client

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@embracesql/client - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

6

package.json
{
"name": "@embracesql/client",
"version": "0.1.2",
"version": "0.1.3",
"description": "Connects to EmbraceSQL over HTTP/S from browser and node.",

@@ -13,5 +13,5 @@ "type": "module",

"dependencies": {
"@embracesql/shared": "^0.1.2"
"@embracesql/shared": "^0.1.3"
},
"gitHead": "8f9395afff4f331cde0761a283fea630c2d43a4f"
"gitHead": "edeebbd5811d60be38bba6c04df81b7013349f1a"
}
import {
EmbraceSQLRequest,
EmbraceSQLResponse,
HasHeaders,
InvokeQueryOptions,
sleep,
} from "@embracesql/shared";

@@ -48,3 +48,3 @@

Response,
Options extends HasHeaders = HasHeaders,
Options extends InvokeQueryOptions = InvokeQueryOptions,
>(

@@ -67,25 +67,42 @@ request: EmbraceSQLRequest<Parameters, Values, Options>,

};
const response = await fetch(this.props.url, {
...props,
method: "POST",
cache: "no-cache",
redirect: "follow",
body: JSON.stringify({
...request,
options: {
// combine client and request options
...(this.props.options ?? {}),
// with request options taking preference
...(request.options ?? {}),
},
}),
});
// it'll be JSON back or an exception
return (await response.json()) as unknown as EmbraceSQLResponse<
Response,
Parameters,
Values,
Options
>;
let finalError: Error | undefined = undefined;
for (let retry = 0; retry <= (request?.options?.retries ?? 0); retry += 1) {
try {
// actual trip to the network happens here
const response = await fetch(this.props.url, {
...props,
method: "POST",
cache: "no-cache",
redirect: "follow",
body: JSON.stringify({
...request,
options: {
// combine client and request options
...(this.props.options ?? {}),
// with request options taking preference
...(request.options ?? {}),
},
}),
});
// it'll be JSON back or an exception
return (await response.json()) as unknown as EmbraceSQLResponse<
Response,
Parameters,
Values,
Options
>;
} catch (e) {
finalError = e as Error;
// this is the exponential backoff part
if (retry > 0) {
await sleep(100 * 2 ** retry);
}
}
}
// if we got here, we're past all the retries and it is time to throw
throw finalError;
}

@@ -92,0 +109,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc