Skip to content

Commit 00e9c9a

Browse files
authored
Merge pull request #68 from libsql/hrana3
Use Hrana 3 when available
2 parents 10924f7 + b129ef1 commit 00e9c9a

File tree

12 files changed

+224
-192
lines changed

12 files changed

+224
-192
lines changed

.github/workflows/ci.yaml

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ jobs:
88
"node-test":
99
name: "Build and test on Node.js"
1010
runs-on: ubuntu-latest
11+
env: {"NODE_OPTIONS": "--trace-warnings"}
1112
steps:
1213
- name: "Checkout this repo"
1314
uses: actions/checkout@v3
@@ -35,30 +36,28 @@ jobs:
3536
- name: "Build"
3637
run: "npm run build"
3738

38-
- name: "Test Hrana 1 over WebSockets"
39+
- name: "Test Hrana 1 over WebSocket"
3940
run: "python hrana-test-server/server_v1.py npm test"
40-
env:
41-
"URL": "ws://localhost:8080"
42-
"SERVER": "test_v1"
43-
- name: "Test Hrana 2 over WebSockets"
41+
env: {"URL": "ws://localhost:8080", "SERVER": "test_v1"}
42+
- name: "Test Hrana 2 over WebSocket"
4443
run: "python hrana-test-server/server_v2.py npm test"
45-
env:
46-
"URL": "ws://localhost:8080"
47-
"SERVER": "test_v2"
44+
env: {"URL": "ws://localhost:8080", "SERVER": "test_v2"}
4845
- name: "Test Hrana 2 over HTTP"
4946
run: "python hrana-test-server/server_v2.py npm test"
50-
env:
51-
"URL": "http://localhost:8080"
52-
"SERVER": "test_v2"
47+
env: {"URL": "http://localhost:8080", "SERVER": "test_v2"}
48+
- name: "Test Hrana 3 over WebSocket"
49+
run: "python hrana-test-server/server_v3.py npm test"
50+
env: {"URL": "ws://localhost:8080", "SERVER": "test_v3"}
51+
- name: "Test Hrana 3 over HTTP"
52+
run: "python hrana-test-server/server_v3.py npm test"
53+
env: {"URL": "http://localhost:8080", "SERVER": "test_v3"}
5354
- name: "Test local file"
5455
run: "npm test"
55-
env:
56-
"URL": "file:///tmp/test.db"
56+
env: {"URL": "file:///tmp/test.db"}
5757

5858
- name: "Test example"
5959
run: "node examples/example.js"
60-
env:
61-
"URL": "file:///tmp/example.db"
60+
env: {"URL": "file:///tmp/example.db"}
6261

6362
"workers-test":
6463
name: "Build and test with Cloudflare Workers"
@@ -72,7 +71,7 @@ jobs:
7271
- name: "Setup Node.js"
7372
uses: actions/setup-node@v3
7473
with:
75-
node-version: "19.x"
74+
node-version: "lts/Hydrogen"
7675
cache: "npm"
7776
- name: "Install npm dependencies"
7877
run: "npm ci"
@@ -95,37 +94,37 @@ jobs:
9594
- name: "Install npm dependencies of the Workers test"
9695
run: "cd smoke_test/workers && npm link ../.."
9796

98-
- name: "Local test with Hrana 1 over WebSockets"
97+
- name: "Local test with Hrana 1 over WebSocket"
9998
run: "cd smoke_test/workers && python ../../hrana-test-server/server_v1.py node test.js"
100-
env:
101-
"LOCAL": "1"
102-
"URL": "ws://localhost:8080"
103-
- name: "Local test with Hrana 2 over WebSockets"
99+
env: {"LOCAL": "1", "URL": "ws://localhost:8080"}
100+
- name: "Local test with Hrana 2 over WebSocket"
104101
run: "cd smoke_test/workers && python ../../hrana-test-server/server_v2.py node test.js"
105-
env:
106-
"LOCAL": "1"
107-
"URL": "ws://localhost:8080"
102+
env: {"LOCAL": "1", "URL": "ws://localhost:8080"}
108103
- name: "Local test with Hrana 2 over HTTP"
109104
run: "cd smoke_test/workers && python ../../hrana-test-server/server_v2.py node test.js"
110-
env:
111-
"LOCAL": "1"
112-
"URL": "http://localhost:8080"
105+
env: {"LOCAL": "1", "URL": "http://localhost:8080"}
106+
- name: "Local test with Hrana 3 over WebSocket"
107+
run: "cd smoke_test/workers && python ../../hrana-test-server/server_v3.py node test.js"
108+
env: {"LOCAL": "1", "URL": "ws://localhost:8080"}
109+
- name: "Local test with Hrana 3 over HTTP"
110+
run: "cd smoke_test/workers && python ../../hrana-test-server/server_v3.py node test.js"
111+
env: {"LOCAL": "1", "URL": "http://localhost:8080"}
113112

114-
- name: "Non-local test with Hrana 1 over WebSockets"
113+
- name: "Non-local test with Hrana 1 over WebSocket"
115114
run: "cd smoke_test/workers && python ../../hrana-test-server/server_v1.py node test.js"
116-
env:
117-
"LOCAL": "0"
118-
"URL": "ws://localhost:8080"
119-
- name: "Non-local test with Hrana 2 over WebSockets"
115+
env: {"LOCAL": "0", "URL": "ws://localhost:8080"}
116+
- name: "Non-local test with Hrana 2 over WebSocket"
120117
run: "cd smoke_test/workers && python ../../hrana-test-server/server_v2.py node test.js"
121-
env:
122-
"LOCAL": "0"
123-
"URL": "ws://localhost:8080"
118+
env: {"LOCAL": "0", "URL": "ws://localhost:8080"}
124119
- name: "Non-local test with Hrana 2 over HTTP"
125120
run: "cd smoke_test/workers && python ../../hrana-test-server/server_v2.py node test.js"
126-
env:
127-
"LOCAL": "0"
128-
"URL": "http://localhost:8080"
121+
env: {"LOCAL": "0", "URL": "http://localhost:8080"}
122+
- name: "Non-local test with Hrana 3 over WebSocket"
123+
run: "cd smoke_test/workers && python ../../hrana-test-server/server_v3.py node test.js"
124+
env: {"LOCAL": "0", "URL": "ws://localhost:8080"}
125+
- name: "Non-local test with Hrana 3 over HTTP"
126+
run: "cd smoke_test/workers && python ../../hrana-test-server/server_v3.py node test.js"
127+
env: {"LOCAL": "0", "URL": "http://localhost:8080"}
129128

130129
"vercel-test":
131130
name: "Build and test with Vercel Edge Functions"
@@ -139,7 +138,7 @@ jobs:
139138
- name: "Setup Node.js"
140139
uses: actions/setup-node@v3
141140
with:
142-
node-version: "19.x"
141+
node-version: "lts/Hydrogen"
143142
cache: "npm"
144143
- name: "Install npm dependencies"
145144
run: "npm ci"
@@ -162,15 +161,18 @@ jobs:
162161
- name: "Install npm dependencies of the Vercel test"
163162
run: "cd smoke_test/vercel && npm install"
164163

165-
- name: "Test with Hrana 1 over WebSockets"
164+
- name: "Test with Hrana 1 over WebSocket"
166165
run: "cd smoke_test/vercel && python ../../hrana-test-server/server_v1.py node test.js"
167-
env:
168-
"URL": "ws://localhost:8080"
169-
- name: "Test with Hrana 2 over WebSockets"
166+
env: {"URL": "ws://localhost:8080"}
167+
- name: "Test with Hrana 2 over WebSocket"
170168
run: "cd smoke_test/vercel && python ../../hrana-test-server/server_v2.py node test.js"
171-
env:
172-
"URL": "ws://localhost:8080"
169+
env: {"URL": "ws://localhost:8080"}
173170
- name: "Test with Hrana 2 over HTTP"
174171
run: "cd smoke_test/vercel && python ../../hrana-test-server/server_v2.py node test.js"
175-
env:
176-
"URL": "http://localhost:8080"
172+
env: {"URL": "http://localhost:8080"}
173+
- name: "Test with Hrana 3 over WebSocket"
174+
run: "cd smoke_test/vercel && python ../../hrana-test-server/server_v3.py node test.js"
175+
env: {"URL": "ws://localhost:8080"}
176+
- name: "Test with Hrana 3 over HTTP"
177+
run: "cd smoke_test/vercel && python ../../hrana-test-server/server_v3.py node test.js"
178+
env: {"URL": "http://localhost:8080"}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
- Updated `@libsql/hrana-client` to version 0.5.0, which implements Hrana 3
6+
- Dropped workarounds for broken WebSocket support in Miniflare 2
7+
58
## 0.3.1 -- 2023-07-20
69

710
- Added `ResultSet.toJSON()` to provide better JSON serialization. ([#61](https://github.com/libsql/libsql-client-ts/pull/61))

package-lock.json

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@
8383
"typedoc": "rm -rf ./docs && typedoc"
8484
},
8585

86+
"dependencies": {
87+
"@libsql/hrana-client": "^0.5.0-pre.2",
88+
"better-sqlite3": "^8.0.1",
89+
"js-base64": "^3.7.5"
90+
},
8691
"devDependencies": {
8792
"@types/better-sqlite3": "^7.6.3",
8893
"@types/jest": "^29.2.5",
@@ -91,10 +96,5 @@
9196
"ts-jest": "^29.0.5",
9297
"typedoc": "^0.23.28",
9398
"typescript": "^4.9.4"
94-
},
95-
"dependencies": {
96-
"@libsql/hrana-client": "^0.4.3",
97-
"better-sqlite3": "^8.0.1",
98-
"js-base64": "^3.7.5"
9999
}
100100
}

smoke_test/vercel/test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use strict";
12
const { spawn } = require("node:child_process");
23
const fs = require("node:fs");
34
const fetch = require("node-fetch");
@@ -122,10 +123,13 @@ async function main() {
122123
console.info(`Creating a tunnel to ${url}...`);
123124
const tunnel = await localtunnel({
124125
port: url.port,
125-
local_host: url.hostname,
126+
// NOTE: if we specify `local_host`, `localtunnel` will try to rewrite the `Host` header in the
127+
// tunnelled HTTP requests. Unfortunately, they do it in a very silly way by converting the
128+
// tunnelled data to a string, thus corrupting the request body.
129+
//local_host: url.hostname,
126130
});
127131

128-
clientUrlInsideVercel = new URL(tunnel.url);
132+
let clientUrlInsideVercel = new URL(tunnel.url);
129133
if (url.protocol === "http:") {
130134
clientUrlInsideVercel.protocol = "https:";
131135
} else if (url.protocol === "ws:") {

smoke_test/workers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"devDependencies": {
33
"localtunnel": "^2.0.2",
4-
"wrangler": "^2.20.0"
4+
"wrangler": "^3.5.1"
55
}
66
}

smoke_test/workers/test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use strict";
12
const localtunnel = require("localtunnel");
23
const wrangler = require("wrangler");
34

@@ -15,7 +16,10 @@ async function main() {
1516
console.info(`Creating an tunnel to ${url}...`);
1617
tunnel = await localtunnel({
1718
port: url.port,
18-
local_host: url.hostname,
19+
// NOTE: if we specify `local_host`, `localtunnel` will try to rewrite the `Host` header in the
20+
// tunnelled HTTP requests. Unfortunately, they do it in a very silly way by converting the
21+
// tunnelled data to a string, thus corrupting the request body.
22+
//local_host: url.hostname,
1923
});
2024

2125
clientUrlInsideWorker = new URL(tunnel.url);

0 commit comments

Comments
 (0)