akanjs 3.2.0-rc.25 → 3.2.0-rc.26
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 +2 -0
- package/fetch/client/fetchClient.ts +3 -11
- package/fetch/client/httpClient.ts +1 -2
- package/fetch/client/requestScope.ts +11 -2
- package/package.json +1 -1
- package/server/di/stageFailedError.ts +10 -0
- package/server/di/utils.ts +2 -1
- package/server/index.ts +1 -0
- package/types/fetch/client/requestScope.d.ts +6 -1
- package/types/server/di/stageFailedError.d.ts +5 -0
- package/types/server/index.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -735,6 +735,7 @@
|
|
|
735
735
|
**Upgrading.** The solid SQLite open used to reject with SQLite's error itself. Code that matched that error's `code` (`SQLITE_BUSY` or `SQLITE_LOCKED`) now finds it on `error.cause`. You can also branch on `AkanError.is(error, "databaseLocked")`.
|
|
736
736
|
|
|
737
737
|
- 5757156: During a server render, a `fetch.*` query shares a request only with calls that end up with the same `timeout` and `retry`: the call's own, or else its endpoint's timeout and its client's (`clone({ retry })`, `setTimeout`). Before, the render shared one request between every call with the same endpoint, arguments and credential, from any client, so the first call's deadline and retry policy applied to all of them. A page's `fetch.isMemoOpen({ timeout: 3_000 })` after a layout's `fetch.isMemoOpen()` waited as long as the layout's call did, up to the client's 30 s default, and a page's `fetch.clone({ retry: { attempts: 4 } })` call ran without retries. Calls that pass no options still share one request per render, as before. The browser's in-flight sharing keys the same way, so a call naming `retry: false` (the default) now joins one that names none.
|
|
738
|
+
- fd125b0: A query that names the default 30 s timeout now shares its request with one that names none, and two queries whose `retry` policies hold the same fields in a different order share theirs, both in a server render and in the browser.
|
|
738
739
|
- 9a2a8c9: The build refuses a `LevelBoundary` or `McpAppRoot` export on an app's root layout: `page/_layout.tsx`, or a grouped or base-path root layout. Akan.js defines both on the root layout it generates and reads neither from an app's layout, so such an export was silently ignored. The error names the export and the file and says why. Remove the export; it never took effect.
|
|
739
740
|
|
|
740
741
|
`akanjs/common` exports `GENERATED_ROOT_LAYOUT_EXPORTS`, the set of those names.
|
|
@@ -1047,6 +1048,7 @@
|
|
|
1047
1048
|
- **`ssr: "block"` writes every boundary in place,** so a blocking page never shows its `.loading()` fallback.
|
|
1048
1049
|
- **Fragments land on their target.** A document opened at a fragment scrolls to the target when React reveals it, if the target was not on the page yet and the visitor has not scrolled; a reload or a back/forward visit keeps the offset the browser restored. A client navigation to another page's fragment lands on the target instead of the top.
|
|
1049
1050
|
|
|
1051
|
+
- fd125b0: `akanjs/server` exports `StageFailedError`, the error a failed DI startup stage throws, so `StageFailedError.is(error)` narrows to a type whose `errors` holds each failed task's error without a cast.
|
|
1050
1052
|
- a5c476a: A gateway stopped while `AkanApp.start()` was still preparing its runtime folder, logs or ops route no longer spawns replicas or listens afterwards, and its `start()` now returns instead of waiting for a stop that has already happened. A server without a gateway stopped while `AkanServer.start({ listen: false })` was opening its log control socket no longer runs its init schedules afterwards.
|
|
1051
1053
|
- 76705dd: `StoreRegistry.build` now reads a root store's state, actions and slices from the merged type rather than inferring them back out of it. That inference grew quadratically with the number of stores. In an app merging about 70 stores, `build` took most of the typecheck, and adding a few more stores failed it with TS2589 ("Type instantiation is excessively deep"). With this change the typecheck cost grows linearly with the store count, and the `st` type is unchanged.
|
|
1052
1054
|
- 206bb69: A store write now costs about one copy of the state, whatever else the root holds. Before, every `set` copied the state twice, compared every key, re-read every `search()` value, and walked every persisted key and every model form. That came to 173 µs at 1,740 keys and 364 µs at 3,480. Now `set` works out the changed keys from the patch and copies the state once. It then recomputes only the `search()` values (when `searchParams` changed) and the `computed()` values whose dependencies changed, and syncs only the persisted keys and form drafts the write touched. That is 38 µs at 1,740 keys and 78 µs at 3,480, the cost of the copy itself.
|
|
@@ -397,13 +397,10 @@ export class FetchClient {
|
|
|
397
397
|
const requestQuery = (requestSignal?: AbortSignal) =>
|
|
398
398
|
this.http.get(url, { headers, baseUrl, timeout, retry: option?.retry, signal: requestSignal });
|
|
399
399
|
|
|
400
|
+
const budget = { timeout: timeout ?? this.http.timeout, retry: option?.retry ?? this.http.retry };
|
|
400
401
|
const claim = baseUrl
|
|
401
402
|
? { value: requestQuery(signal), owned: true }
|
|
402
|
-
: this.#claimQuery(makeRequestQueryCacheKey(this.origin, url, headers), requestQuery,
|
|
403
|
-
signal,
|
|
404
|
-
timeout,
|
|
405
|
-
retry: option?.retry,
|
|
406
|
-
});
|
|
403
|
+
: this.#claimQuery(makeRequestQueryCacheKey(this.origin, url, headers, budget), requestQuery, signal);
|
|
407
404
|
recordRequestQuery({ key, args: Object.fromEntries(argMap), returns: endpoint.returns, value: claim.value });
|
|
408
405
|
const response = await this.#untilAborted(claim.value, signal);
|
|
409
406
|
const payload = claim.owned ? response : deepCopy(response);
|
|
@@ -440,12 +437,7 @@ export class FetchClient {
|
|
|
440
437
|
}
|
|
441
438
|
}
|
|
442
439
|
|
|
443
|
-
#claimQuery(
|
|
444
|
-
cacheKey: string,
|
|
445
|
-
requestQuery: (signal?: AbortSignal) => Promise<unknown>,
|
|
446
|
-
{ signal, timeout, retry }: { signal?: AbortSignal; timeout?: number | false; retry?: RetryPolicy | false },
|
|
447
|
-
) {
|
|
448
|
-
const claimKey = `${cacheKey}\n${timeout ?? this.http.timeout}\n${JSON.stringify(retry ?? this.http.retry)}`;
|
|
440
|
+
#claimQuery(claimKey: string, requestQuery: (signal?: AbortSignal) => Promise<unknown>, signal?: AbortSignal) {
|
|
449
441
|
if (getRequestStore()) return claimRequestQuery(claimKey, () => requestQuery());
|
|
450
442
|
if (typeof window === "undefined") return { value: requestQuery(signal), owned: true };
|
|
451
443
|
return { value: this.#inflight.claim(claimKey, requestQuery, signal), owned: true };
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
type RestoredError,
|
|
7
7
|
restoreRemoteError,
|
|
8
8
|
} from "./remoteError";
|
|
9
|
+
import { DEFAULT_TIMEOUT_MS } from "./requestScope";
|
|
9
10
|
|
|
10
11
|
export interface HttpClientOptions {
|
|
11
12
|
headers?: Record<string, string>;
|
|
@@ -47,8 +48,6 @@ const unexpectedResponseKey = "base.error.unexpectedResponse";
|
|
|
47
48
|
const dictionaryErrorKey = /^\w+\.error\./;
|
|
48
49
|
const transportDetailLimit = 200;
|
|
49
50
|
|
|
50
|
-
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
51
|
-
|
|
52
51
|
export class HttpClient {
|
|
53
52
|
static readonly #logger = new Logger("HttpClient");
|
|
54
53
|
readonly baseUrl: string;
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { getEnv, getWsPrefix } from "akanjs/base";
|
|
2
|
-
import { trimTrailingSlashes } from "akanjs/common";
|
|
2
|
+
import { type RetryPolicy, trimTrailingSlashes } from "akanjs/common";
|
|
3
3
|
|
|
4
|
-
export const
|
|
4
|
+
export const DEFAULT_TIMEOUT_MS = 30_000;
|
|
5
|
+
|
|
6
|
+
export const makeRequestQueryCacheKey = (
|
|
7
|
+
origin: string,
|
|
8
|
+
url: string,
|
|
9
|
+
headers: Record<string, string>,
|
|
10
|
+
budget: { timeout?: number | false; retry: RetryPolicy | false },
|
|
11
|
+
): string => {
|
|
5
12
|
return JSON.stringify({
|
|
6
13
|
method: "GET",
|
|
7
14
|
origin,
|
|
8
15
|
url,
|
|
9
16
|
headers: Object.entries(headers).sort(([a], [b]) => a.localeCompare(b)),
|
|
17
|
+
timeout: budget.timeout ?? DEFAULT_TIMEOUT_MS,
|
|
18
|
+
retry: JSON.stringify(budget.retry, Object.keys(budget.retry).sort()),
|
|
10
19
|
});
|
|
11
20
|
};
|
|
12
21
|
export const deepCopy = <T>(value: T): T => {
|
package/package.json
CHANGED
package/server/di/utils.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { lowerlize, toError } from "akanjs/common";
|
|
|
3
3
|
import { ConstantRegistry, type FieldObject } from "akanjs/constant";
|
|
4
4
|
import type { InjectInfo } from "akanjs/service";
|
|
5
5
|
import type { DatabaseModule, ServiceModule } from "../akanLib";
|
|
6
|
+
import { StageFailedError } from "./stageFailedError";
|
|
6
7
|
|
|
7
8
|
interface StageTask {
|
|
8
9
|
label: string;
|
|
@@ -142,7 +143,7 @@ export const throwStageFailures = (
|
|
|
142
143
|
const summary = failures.map((f) => ` • ${f.label}: ${reasonMessage(f.reason)}`).join("\n");
|
|
143
144
|
const errors = failures.map((f) => toError(f.reason));
|
|
144
145
|
const message = `[DI:${stageLabel}] ${failures.length}/${total} task(s) failed:\n${summary}`;
|
|
145
|
-
throw
|
|
146
|
+
throw new StageFailedError(message, errors);
|
|
146
147
|
};
|
|
147
148
|
|
|
148
149
|
export const reasonMessage = (reason: unknown): string => {
|
package/server/index.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { type RetryPolicy } from "akanjs/common";
|
|
2
|
+
export declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
3
|
+
export declare const makeRequestQueryCacheKey: (origin: string, url: string, headers: Record<string, string>, budget: {
|
|
4
|
+
timeout?: number | false;
|
|
5
|
+
retry: RetryPolicy | false;
|
|
6
|
+
}) => string;
|
|
2
7
|
export declare const deepCopy: <T>(value: T) => T;
|
|
3
8
|
export declare const normalizeOrigin: (origin: string) => string;
|
|
4
9
|
export declare const sameOrigin: (a: string, b: string) => boolean;
|
package/types/server/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { type BuildChangesPayload, type BuilderControl, type BuilderCsrReq, type
|
|
|
6
6
|
export { type AkanConsoleContext, type AkanConsoleOptions, assertAkanConsoleAllowed, createAkanConsoleContext, createAkanConsoleLogCommands, evaluateAkanConsoleInput, getAkanConsoleMethods, isAkanConsoleInputComplete, parseAkanConsoleQuery, startAkanConsole, } from "./console.d.ts";
|
|
7
7
|
export { Transaction, Try } from "./decorators.d.ts";
|
|
8
8
|
export { type ArgType, type ConstantData, type ConstantFieldKind, type ConstantFieldNode, type ConstantModelNode, type ConstantModelView, type ConstantModelViewKey, ConstantSerializer, type DepEdge, type DepEdgeKind, type DepNode, type DepNodeKind, type DepsData, DepsSerializer, type DepsSerializerContext, type DevtoolsApp, type DevtoolsEnvelope, type DevtoolsIndex, DevtoolsJson, DevtoolsRouter, type DevtoolsRouterContext, type DictionaryData, type DictionaryModuleNode, type EndpointNode, type EnumNode, type FieldType, type FilterArg, type InternalNode, type InternalType, type RelationEdge, type RouteRow, type SerializedArg, type SerializedReturns, type SignalData, type SignalNode, SignalSerializer, type SignalSerializerContext, type SliceNode, type Unserializable, } from "./devtools.d.ts";
|
|
9
|
+
export { StageFailedError } from "./di/stageFailedError.d.ts";
|
|
9
10
|
export type { ChangeBatch, ChangeKind } from "./hmr/wsHub.d.ts";
|
|
10
11
|
export { MachineAccount, type MachineProof, MachineToken, type MachineTokenIssueOptions, type MachineTokenVerdict, } from "./machine.d.ts";
|
|
11
12
|
export { DocPath, type DocSlot, type MigrationAction, type MigrationApplyResult, type MigrationArgs, type MigrationChange, MigrationChangeLog, type MigrationChangeOp, MigrationChanges, MigrationCommand, type MigrationCommandResult, MigrationContext, type MigrationContextOption, MigrationDefinition, type MigrationEntry, MigrationError, type MigrationErrorCode, type MigrationGet, MigrationLedger, type MigrationListItem, MigrationLock, type MigrationParamInfo, type MigrationParamOption, type MigrationParamSpec, MigrationParams, type MigrationParamValue, type MigrationPatch, type MigrationPlan, type MigrationPlanResult, type MigrationPruneResult, MigrationPulse, type MigrationRevertOutcome, type MigrationRewriteOption, type MigrationRollbackResult, type MigrationRollbackRun, type MigrationRun, type MigrationRunKind, MigrationRunner, type MigrationRunnerOption, type MigrationRunStatus, MigrationScope, type MigrationScopeOption, type MigrationSettings, type MigrationSkip, type MigrationState, type MigrationStatus, Migrations, MigrationTable, type MigrationVerifyResult, migration, migrationActions, } from "./migration.d.ts";
|