@ultimabase/http 0.5.0 → 0.6.0-canary.20261106165128
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.
- package/CHANGELOG.md +10 -0
- package/dist/backlog.d.ts +14 -0
- package/dist/backlog.d.ts.map +1 -0
- package/dist/backlog.js +20 -0
- package/dist/internal.d.ts +2 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +2 -1
- package/dist/pages.d.ts +5 -0
- package/dist/pages.d.ts.map +1 -1
- package/dist/pages.js +5 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +3 -1
- package/package.json +3 -3
- package/src/backlog.ts +27 -0
- package/src/internal.ts +2 -0
- package/src/pages.ts +7 -0
- package/src/server.ts +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @ultimabase/http
|
|
2
2
|
|
|
3
|
+
## 0.6.0-canary.20261106165128
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a47bbc4: A storm of connections no longer fails. The server's connection queue holds 4096, and at most 8 connections open at once. A socket closed by a failure of the server now gets `1013`, which `graphql-ws` retries, where it got `4403`: `4403` now means refused, and only that. `liveFetch` reconnects at a random moment of its wait, so that clients cut together do not come back together.
|
|
8
|
+
- Updated dependencies [41b5dca]
|
|
9
|
+
- Updated dependencies [41b5dca]
|
|
10
|
+
- Updated dependencies [41b5dca]
|
|
11
|
+
- ultimabase@0.6.0-canary.20261106165128
|
|
12
|
+
|
|
3
13
|
## 0.5.0
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The parts of a live message that say what it costs. */
|
|
2
|
+
type Costed = {
|
|
3
|
+
readonly kind: string;
|
|
4
|
+
readonly rows?: readonly unknown[];
|
|
5
|
+
readonly changes?: readonly unknown[];
|
|
6
|
+
};
|
|
7
|
+
/** What a live read sent since its client's buffer was last not full. */
|
|
8
|
+
export declare class Backlog {
|
|
9
|
+
#private;
|
|
10
|
+
/** Whether `message` is sent, or dropped until the window comes again. */
|
|
11
|
+
takes(full: boolean, message: Costed): boolean;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=backlog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backlog.d.ts","sourceRoot":"","sources":["../src/backlog.ts"],"names":[],"mappings":"AAGA,0DAA0D;AAC1D,KAAK,MAAM,GAAG;IACb,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,OAAO,EAAE,CAAA;IAClC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,OAAO,EAAE,CAAA;CACrC,CAAA;AAED,yEAAyE;AACzE,qBAAa,OAAO;;IAInB,0EAA0E;IAC1E,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAS7C;CACD"}
|
package/dist/backlog.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// What a client whose buffer is full is still sent (D-254): its changes, as long
|
|
2
|
+
// as they cost less than the whole window it would get instead.
|
|
3
|
+
/** What a live read sent since its client's buffer was last not full. */
|
|
4
|
+
export class Backlog {
|
|
5
|
+
#shown = 0;
|
|
6
|
+
#cost = 0;
|
|
7
|
+
/** Whether `message` is sent, or dropped until the window comes again. */
|
|
8
|
+
takes(full, message) {
|
|
9
|
+
if (!full) {
|
|
10
|
+
this.#cost = 0;
|
|
11
|
+
if (message.rows !== undefined)
|
|
12
|
+
this.#shown = message.rows.length;
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
if (message.changes === undefined)
|
|
16
|
+
return false;
|
|
17
|
+
this.#cost += message.changes.length + 1;
|
|
18
|
+
return this.#cost <= this.#shown;
|
|
19
|
+
}
|
|
20
|
+
}
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type { Args, At, Change, Limits, Page, Pagination, Relay, } from './pages.ts';
|
|
2
|
-
export { applied, connection, countedPage, pageArgs, pageOf, readsNoRow, rowOf, rowsOf, } from './pages.ts';
|
|
2
|
+
export { applied, endsOf, connection, countedPage, pageArgs, pageOf, readsNoRow, rowOf, rowsOf, } from './pages.ts';
|
|
3
|
+
export { Backlog } from './backlog.ts';
|
|
3
4
|
export type { Node, Served, ServedOneOf } from './transport.ts';
|
|
4
5
|
export { badInput, backOf, declared, isNode, jsonSchemaOf, oneOfsOf, plural, readable, readableOneOfs, readableVirtuals, run, } from './transport.ts';
|
|
5
6
|
//# sourceMappingURL=internal.d.ts.map
|
package/dist/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAEA,YAAY,EACX,IAAI,EACJ,EAAE,EACF,MAAM,EACN,MAAM,EACN,IAAI,EACJ,UAAU,EACV,KAAK,GACL,MAAM,YAAY,CAAA;AACnB,OAAO,EACN,OAAO,EACP,UAAU,EACV,WAAW,EACX,QAAQ,EACR,MAAM,EACN,UAAU,EACV,KAAK,EACL,MAAM,GACN,MAAM,YAAY,CAAA;AACnB,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,EACN,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,GAAG,GACH,MAAM,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAEA,YAAY,EACX,IAAI,EACJ,EAAE,EACF,MAAM,EACN,MAAM,EACN,IAAI,EACJ,UAAU,EACV,KAAK,GACL,MAAM,YAAY,CAAA;AACnB,OAAO,EACN,OAAO,EACP,MAAM,EACN,UAAU,EACV,WAAW,EACX,QAAQ,EACR,MAAM,EACN,UAAU,EACV,KAAK,EACL,MAAM,GACN,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,EACN,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,GAAG,GACH,MAAM,gBAAgB,CAAA"}
|
package/dist/internal.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { applied, connection, countedPage, pageArgs, pageOf, readsNoRow, rowOf, rowsOf, } from './pages.js';
|
|
1
|
+
export { applied, endsOf, connection, countedPage, pageArgs, pageOf, readsNoRow, rowOf, rowsOf, } from './pages.js';
|
|
2
|
+
export { Backlog } from './backlog.js';
|
|
2
3
|
export { badInput, backOf, declared, isNode, jsonSchemaOf, oneOfsOf, plural, readable, readableOneOfs, readableVirtuals, run, } from './transport.js';
|
package/dist/pages.d.ts
CHANGED
|
@@ -43,6 +43,11 @@ export type Connection<N> = {
|
|
|
43
43
|
};
|
|
44
44
|
/** The rows of a Relay read, without the one read to look ahead. */
|
|
45
45
|
export declare function connection<N>(rows: readonly Row[], page: Relay, node: (row: Row) => N): Connection<N>;
|
|
46
|
+
/**
|
|
47
|
+
* The first and last of `ids` as rows: a live window's page info without the
|
|
48
|
+
* rows between (D-253).
|
|
49
|
+
*/
|
|
50
|
+
export declare const endsOf: (ids: readonly string[]) => readonly Row[];
|
|
46
51
|
/** Whether a counted page reads no row: `first` or `last` 0, no cursor (D-226). */
|
|
47
52
|
export declare const readsNoRow: (page: Page) => boolean;
|
|
48
53
|
/** A page read as its count alone, which tells whether rows follow (D-226). */
|
package/dist/pages.d.ts.map
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C,CAAC,IACjB;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC3B;IAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAA;AAExD,yEAAyE;AACzE,wBAAgB,OAAO,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,EAC3D,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,OAAO,EAAE,SAAS,MAAM,CAAC,CAAC,CAAC,EAAE,EAC7B,IAAI,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GACpB,CAAC,EAAE,CAgBL"}
|
package/dist/pages.js
CHANGED
|
@@ -100,6 +100,11 @@ export function connection(rows, page, node) {
|
|
|
100
100
|
},
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* The first and last of `ids` as rows: a live window's page info without the
|
|
105
|
+
* rows between (D-253).
|
|
106
|
+
*/
|
|
107
|
+
export const endsOf = (ids) => ids.map((id) => ({ id }));
|
|
103
108
|
/** Whether a counted page reads no row: `first` or `last` 0, no cursor (D-226). */
|
|
104
109
|
export const readsNoRow = (page) => page.relay?.size === 0 && page.read['cursor'] === undefined;
|
|
105
110
|
/** A page read as its count alone, which tells whether rows follow (D-226). */
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAEvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAGxC,iDAAiD;AACjD,w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
|
@@ -29,6 +29,8 @@ export function drainOf(option) {
|
|
|
29
29
|
return ms;
|
|
30
30
|
throw new Refused(`drain is ${ms}, not a whole number of milliseconds.`);
|
|
31
31
|
}
|
|
32
|
+
/** The connections waiting to be accepted; the system caps it at its own. */
|
|
33
|
+
const backlog = 4096;
|
|
32
34
|
export async function listening(server, port) {
|
|
33
35
|
await new Promise((done, fail) => {
|
|
34
36
|
const refused = (error) => {
|
|
@@ -38,7 +40,7 @@ export async function listening(server, port) {
|
|
|
38
40
|
: error);
|
|
39
41
|
};
|
|
40
42
|
server.once('error', refused);
|
|
41
|
-
server.listen(port, () => {
|
|
43
|
+
server.listen({ port, backlog }, () => {
|
|
42
44
|
server.off('error', refused);
|
|
43
45
|
done();
|
|
44
46
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimabase/http",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-canary.20261106165128",
|
|
4
4
|
"description": "An HTTP server for UltimaBase: Hono routes that read the caller, CORS and a body limit.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"ipaddr.js": "2.5.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"ultimabase": "
|
|
41
|
+
"ultimabase": "0.6.0-canary.20261106165128"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"ultimabase": "0.
|
|
44
|
+
"ultimabase": "0.6.0-canary.20261106165128",
|
|
45
45
|
"vite": "8.3.4",
|
|
46
46
|
"vitest": "5.0.5"
|
|
47
47
|
}
|
package/src/backlog.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// What a client whose buffer is full is still sent (D-254): its changes, as long
|
|
2
|
+
// as they cost less than the whole window it would get instead.
|
|
3
|
+
|
|
4
|
+
/** The parts of a live message that say what it costs. */
|
|
5
|
+
type Costed = {
|
|
6
|
+
readonly kind: string
|
|
7
|
+
readonly rows?: readonly unknown[]
|
|
8
|
+
readonly changes?: readonly unknown[]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** What a live read sent since its client's buffer was last not full. */
|
|
12
|
+
export class Backlog {
|
|
13
|
+
#shown = 0
|
|
14
|
+
#cost = 0
|
|
15
|
+
|
|
16
|
+
/** Whether `message` is sent, or dropped until the window comes again. */
|
|
17
|
+
takes(full: boolean, message: Costed): boolean {
|
|
18
|
+
if (!full) {
|
|
19
|
+
this.#cost = 0
|
|
20
|
+
if (message.rows !== undefined) this.#shown = message.rows.length
|
|
21
|
+
return true
|
|
22
|
+
}
|
|
23
|
+
if (message.changes === undefined) return false
|
|
24
|
+
this.#cost += message.changes.length + 1
|
|
25
|
+
return this.#cost <= this.#shown
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/internal.ts
CHANGED
|
@@ -11,6 +11,7 @@ export type {
|
|
|
11
11
|
} from './pages.ts'
|
|
12
12
|
export {
|
|
13
13
|
applied,
|
|
14
|
+
endsOf,
|
|
14
15
|
connection,
|
|
15
16
|
countedPage,
|
|
16
17
|
pageArgs,
|
|
@@ -19,6 +20,7 @@ export {
|
|
|
19
20
|
rowOf,
|
|
20
21
|
rowsOf,
|
|
21
22
|
} from './pages.ts'
|
|
23
|
+
export { Backlog } from './backlog.ts'
|
|
22
24
|
export type { Node, Served, ServedOneOf } from './transport.ts'
|
|
23
25
|
export {
|
|
24
26
|
badInput,
|
package/src/pages.ts
CHANGED
|
@@ -163,6 +163,13 @@ export function connection<N>(
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
/**
|
|
167
|
+
* The first and last of `ids` as rows: a live window's page info without the
|
|
168
|
+
* rows between (D-253).
|
|
169
|
+
*/
|
|
170
|
+
export const endsOf = (ids: readonly string[]): readonly Row[] =>
|
|
171
|
+
ids.map((id) => ({ id }))
|
|
172
|
+
|
|
166
173
|
/** Whether a counted page reads no row: `first` or `last` 0, no cursor (D-226). */
|
|
167
174
|
export const readsNoRow = (page: Page): boolean =>
|
|
168
175
|
page.relay?.size === 0 && page.read['cursor'] === undefined
|
package/src/server.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// The port the server listens on, and its listening (D-106); the body
|
|
2
|
-
// limit and the drain (D-223).
|
|
2
|
+
// limit and the drain (D-223); its connection queue (D-276).
|
|
3
3
|
import type { Server } from 'node:http'
|
|
4
4
|
import { createServer } from 'node:http'
|
|
5
5
|
import type { Duplex } from 'node:stream'
|
|
@@ -37,6 +37,9 @@ export function drainOf(option: number | undefined): number {
|
|
|
37
37
|
throw new Refused(`drain is ${ms}, not a whole number of milliseconds.`)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/** The connections waiting to be accepted; the system caps it at its own. */
|
|
41
|
+
const backlog = 4096
|
|
42
|
+
|
|
40
43
|
export async function listening(server: Server, port: number): Promise<number> {
|
|
41
44
|
await new Promise<void>((done, fail) => {
|
|
42
45
|
const refused = (error: Error) => {
|
|
@@ -51,7 +54,7 @@ export async function listening(server: Server, port: number): Promise<number> {
|
|
|
51
54
|
)
|
|
52
55
|
}
|
|
53
56
|
server.once('error', refused)
|
|
54
|
-
server.listen(port, () => {
|
|
57
|
+
server.listen({ port, backlog }, () => {
|
|
55
58
|
server.off('error', refused)
|
|
56
59
|
done()
|
|
57
60
|
})
|