chore(deps): upgrade Effect to 4.0.2 (#17571)
Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
aa8c6662e2
commit
91a6646efd
28 files changed
+608
-548
No files matched your search
@@ -7,16 +7,17 @@ export interface SqlStatementCounter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts `sql.execute` spans, which the Effect SQL client opens once per
|
||||
* statement. Spans behave exactly as with the native tracer. Install the same
|
||||
* counter on every runtime under test, otherwise statements run by background
|
||||
* reactors and statements run by request handlers land in different counters.
|
||||
* Counts the client spans the Effect SQL client opens once per statement. Our
|
||||
* SQLite client names them after its `db.system.name`, `sqlite`. Spans behave
|
||||
* exactly as with the native tracer. Install the same counter on every runtime
|
||||
* under test, otherwise statements run by background reactors and statements
|
||||
* run by request handlers land in different counters.
|
||||
*/
|
||||
export function makeSqlStatementCounter(): SqlStatementCounter {
|
||||
let statements = 0;
|
||||
const tracer = Tracer.make({
|
||||
span: (options) => {
|
||||
if (options.name === "sql.execute") statements += 1;
|
||||
if (options.kind === "client" && options.name === "sqlite") statements += 1;
|
||||
return new Tracer.NativeSpan(options);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -30,9 +30,9 @@ export interface TransferBudgetRun {
|
||||
/** The second client resubscribes after the turn from the cursor it held before it. */
|
||||
readonly reconnectThread: WebSocketCatchUpMeasurement;
|
||||
readonly reconnectShell: WebSocketCatchUpMeasurement;
|
||||
/** `sql.execute` spans opened server-wide during the measured turn. */
|
||||
/** SQL statement spans opened server-wide during the measured turn. */
|
||||
readonly measuredTurnSqlStatements: number;
|
||||
/** `sql.execute` spans opened while serving both reconnect catch-ups. */
|
||||
/** SQL statement spans opened while serving both reconnect catch-ups. */
|
||||
readonly reconnectSqlStatements: number;
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ export function formatTransferBudgetReport(runs: ReadonlyArray<TransferBudgetRun
|
||||
"# T3 Code thread transfer budget",
|
||||
"",
|
||||
"Wire values are thread data bytes read from local HTTP and WebSocket sockets. HTTP includes response headers; WebSocket measurement starts after the resumed thread subscription synchronizes. TCP/IP, TLS framing, and the WebSocket upgrade are excluded. WebSocket permessage-deflate is negotiated.",
|
||||
"The measured turn is observed on three sockets at once: one with only the thread subscription (the capped rows), one with only the shell subscription, and a second client holding both. Server egress is the sum of the three. After the turn the second client disconnects and new sockets resubscribe from the cursor it held before the turn, which is the cursor a backgrounded phone would hold. SQL statements are `sql.execute` spans counted across V2 persistence and the HTTP/WebSocket handlers.",
|
||||
"The measured turn is observed on three sockets at once: one with only the thread subscription (the capped rows), one with only the shell subscription, and a second client holding both. Server egress is the sum of the three. After the turn the second client disconnects and new sockets resubscribe from the cursor it held before the turn, which is the cursor a backgrounded phone would hold. SQL statements are the SQL client's per-statement spans, counted across V2 persistence and the HTTP/WebSocket handlers.",
|
||||
`Scenario: ${TRANSFER_HISTORY_TURN_COUNT} historical turns with ${TRANSFER_HISTORY_TOOLS_PER_TURN} command tools and one retained ${formatBytes(TRANSFER_HISTORY_MCP_RESULT_BYTES)} MCP result each, followed by one measured turn with ${TRANSFER_MEASURED_TOOLS} command tools and a retained ${formatBytes(TRANSFER_MEASURED_MCP_RESULT_BYTES)} MCP result. Synthetic V2 domain events exercise persistence, wire projection, and production HTTP/subscription handlers; this does not measure provider adapter ingestion. Payloads contain no user data.`,
|
||||
"",
|
||||
"| Provider | Total thread wire | Budget | Result |",
|
||||
|
||||
@@ -16,13 +16,18 @@ function span(name: string, durationMs: number, endMs: number, exitTag = "Succes
|
||||
});
|
||||
}
|
||||
|
||||
function browserSpan(name: string, status: { code: string; message?: string }) {
|
||||
function browserSpan(
|
||||
name: string,
|
||||
status: { code: string; message?: string },
|
||||
attributes: Record<string, unknown> = {},
|
||||
) {
|
||||
return JSON.stringify({
|
||||
type: "otlp-span",
|
||||
name,
|
||||
durationMs: 1,
|
||||
endTimeUnixNano: "1000000",
|
||||
status,
|
||||
attributes,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -91,10 +96,12 @@ it("reads failures and interrupts of browser spans from their OTLP status", () =
|
||||
const summarizer = makeTraceSpanSummary();
|
||||
[
|
||||
browserSpan("render", { code: "2", message: "boom" }),
|
||||
browserSpan("render", { code: "0" }, { "effect.fiber.interrupted": true }),
|
||||
// Clients before Effect 4.0.2.
|
||||
browserSpan("render", { code: "1", message: "Interrupted" }),
|
||||
browserSpan("render", { code: "1" }),
|
||||
].forEach(summarizer.addLine);
|
||||
|
||||
const [render] = summarizer.finish().spans;
|
||||
assert.deepStrictEqual([render?.count, render?.interrupted, render?.failures], [3, 1, 1]);
|
||||
assert.deepStrictEqual([render?.count, render?.interrupted, render?.failures], [4, 2, 1]);
|
||||
});
|
||||
@@ -30,13 +30,18 @@ const decodeTraceSpanLine = Schema.decodeUnknownOption(
|
||||
// Server (`effect-span`) records.
|
||||
exit: Schema.optional(Schema.Struct({ _tag: Schema.String })),
|
||||
// Browser (`otlp-span`) records. Effect's OTLP tracer writes code "2" for
|
||||
// errors and code "1" with message "Interrupted" for interrupts.
|
||||
// errors. It marks interrupts with an `effect.fiber.interrupted`
|
||||
// attribute; clients before Effect 4.0.2 wrote code "1" with message
|
||||
// "Interrupted" instead.
|
||||
status: Schema.optional(
|
||||
Schema.Struct({
|
||||
code: Schema.optional(Schema.String),
|
||||
message: Schema.optional(Schema.String),
|
||||
}),
|
||||
),
|
||||
attributes: Schema.optional(
|
||||
Schema.Struct({ "effect.fiber.interrupted": Schema.optional(Schema.Unknown) }),
|
||||
),
|
||||
}),
|
||||
),
|
||||
);
|
||||
@@ -77,7 +82,11 @@ export function makeTraceSpanSummary(sinceMs = -Infinity) {
|
||||
lastEndMs = Math.max(lastEndMs, endMs);
|
||||
const stats = byName.get(span.name) ?? { durations: [], interrupted: 0, failures: 0 };
|
||||
stats.durations.push(span.durationMs);
|
||||
if (span.exit?._tag === "Interrupted" || span.status?.message === "Interrupted") {
|
||||
if (
|
||||
span.exit?._tag === "Interrupted" ||
|
||||
span.attributes?.["effect.fiber.interrupted"] === true ||
|
||||
span.status?.message === "Interrupted"
|
||||
) {
|
||||
stats.interrupted += 1;
|
||||
}
|
||||
if (span.exit?._tag === "Failure" || span.status?.code === "2") stats.failures += 1;
|
||||
|
||||
@@ -53,7 +53,7 @@ describe("untraced requests", () => {
|
||||
expect(spanNames).toEqual([]);
|
||||
|
||||
yield* client.get("/api/environment");
|
||||
expect(spanNames).toContain("http.server GET");
|
||||
expect(spanNames).toEqual(["GET"]);
|
||||
}).pipe(
|
||||
Effect.scoped,
|
||||
Effect.provideService(
|
||||
|
||||
@@ -197,6 +197,9 @@ it.effect("rejects unavailable agent access before booting or opening a device",
|
||||
Layer.provideMerge(McpServer.McpServer.layer),
|
||||
Layer.provideMerge(McpToolAccessTestkit.liveThreadsLayer),
|
||||
Layer.provide(layerUnavailable),
|
||||
Layer.provide(
|
||||
ServerConfig.layerTest(process.cwd(), { prefix: "t3-mcp-device-toolkit-test-" }),
|
||||
),
|
||||
Layer.provide(NodeServices.layer),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -17,8 +17,14 @@ import * as Layer from "effect/Layer";
|
||||
import * as Path from "effect/Path";
|
||||
import * as Schema from "effect/Schema";
|
||||
import * as Stream from "effect/Stream";
|
||||
import { McpProtocol, McpSchema, McpServer, Tool, Toolkit } from "effect/ai";
|
||||
import { HttpBody, HttpClient, HttpRouter, HttpServerResponse } from "effect/http";
|
||||
import { McpSchema, McpServer, Tool, Toolkit } from "effect/ai";
|
||||
import {
|
||||
HttpBody,
|
||||
HttpClient,
|
||||
HttpClientRequest,
|
||||
HttpRouter,
|
||||
HttpServerResponse,
|
||||
} from "effect/http";
|
||||
|
||||
import * as ProjectService from "../project/ProjectService.ts";
|
||||
import * as ServerConfig from "../config.ts";
|
||||
@@ -746,17 +752,38 @@ it.effect("sheds log entries before locators when every list is full", () =>
|
||||
it.effect("terminates HTTP MCP sessions with DELETE", () =>
|
||||
Effect.scoped(
|
||||
Effect.gen(function* () {
|
||||
const layerServer = McpServer.layerHttp({
|
||||
name: "MCP termination test",
|
||||
version: "1.0.0",
|
||||
path: "/mcp",
|
||||
protocols: [McpProtocol.v2025_06_18],
|
||||
});
|
||||
const token = "providerTokenWithoutDots";
|
||||
const scope: McpInvocationContext.McpInvocationScope = {
|
||||
environmentId,
|
||||
requestNamespace: "provider-session",
|
||||
thread: {
|
||||
threadId: ThreadId.make("thread-provider"),
|
||||
providerSessionId: "provider-session",
|
||||
providerInstanceId: ProviderInstanceId.make("codex"),
|
||||
},
|
||||
client: undefined,
|
||||
capabilities: new Set(["orchestration"]),
|
||||
issuedAt: 1,
|
||||
};
|
||||
const layerServer = McpHttpServer.layerMcpTransport.pipe(
|
||||
Layer.provide(
|
||||
Layer.mock(McpSessionRegistry.McpSessionRegistry)({
|
||||
resolve: (presented) =>
|
||||
Effect.succeed(
|
||||
presented === token
|
||||
? (scope as McpInvocationContext.McpThreadInvocationScope)
|
||||
: undefined,
|
||||
),
|
||||
}),
|
||||
),
|
||||
);
|
||||
yield* HttpRouter.serve(layerServer, {
|
||||
disableListenLog: true,
|
||||
disableLogger: true,
|
||||
}).pipe(Layer.build);
|
||||
const httpClient = yield* HttpClient.HttpClient;
|
||||
const httpClient = (yield* HttpClient.HttpClient).pipe(
|
||||
HttpClient.mapRequest(HttpClientRequest.bearerToken(token)),
|
||||
);
|
||||
|
||||
const initializeResponse = yield* httpClient.post("/mcp", {
|
||||
headers: { accept: "application/json, text/event-stream" },
|
||||
|
||||
@@ -19,6 +19,7 @@ import packageJson from "../../package.json" with { type: "json" };
|
||||
import * as ServerConfig from "../config.ts";
|
||||
import * as DeviceService from "../device/DeviceService.ts";
|
||||
import * as HtmlRender from "../htmlRender/HtmlRender.ts";
|
||||
import * as ThreadCommandExecutor from "../orchestration-v2/ThreadCommandExecutor.ts";
|
||||
import * as ThreadManagementService from "../orchestration-v2/ThreadManagementService.ts";
|
||||
import * as McpInvocationContext from "./McpInvocationContext.ts";
|
||||
import * as McpToolAccess from "./McpToolAccess.ts";
|
||||
@@ -762,11 +763,25 @@ const registerHtmlPreview = Effect.fn("McpHttpServer.registerHtmlPreview")(funct
|
||||
/**
|
||||
* `McpServer.toolkit` for handlers that declared their access (see
|
||||
* `McpToolAccess`). Every toolkit on `/mcp` registers through this.
|
||||
*
|
||||
* `McpServer.toolkit` asks for every service its tools declare when it
|
||||
* registers them, but the auth middleware provides `McpInvocationContext` to
|
||||
* each request instead. Registration must not get one: the services it
|
||||
* captures would replace the request's.
|
||||
*/
|
||||
export const toolkitRegistration = <Tools extends Record<string, Tool.Any>, EX, RX>(
|
||||
toolkit: Toolkit.Toolkit<Tools>,
|
||||
handlers: McpToolAccess.HandlersLayer<Tools, EX, RX>,
|
||||
) => McpServer.toolkit(toolkit).pipe(Layer.provide(McpToolAccess.HandlersLayer.layer(handlers)));
|
||||
) => {
|
||||
const registration = McpServer.toolkit(toolkit);
|
||||
// @effect-diagnostics-next-line unsafeEffectTypeAssertion:off - the auth middleware provides it per request.
|
||||
const registered = registration as Layer.Layer<
|
||||
never,
|
||||
never,
|
||||
Exclude<Layer.Services<typeof registration>, McpInvocationContext.McpInvocationContext>
|
||||
>;
|
||||
return registered.pipe(Layer.provide(McpToolAccess.HandlersLayer.layer(handlers)));
|
||||
};
|
||||
|
||||
/** A hand-registered tool, also only with handlers that declared their access. */
|
||||
const imageToolRegistration = <Tools extends Record<string, Tool.Any>, A, E, R, EX, RX>(
|
||||
@@ -811,10 +826,10 @@ const layerPreviewControlsRegistration = toolkitRegistration(
|
||||
PreviewControlsHandlers.layer,
|
||||
);
|
||||
|
||||
const layerEnvironmentRegistration = toolkitRegistration(
|
||||
export const layerEnvironmentToolkit = toolkitRegistration(
|
||||
EnvironmentToolkit,
|
||||
EnvironmentHandlers.layer,
|
||||
);
|
||||
).pipe(Layer.provide(ThreadCommandExecutor.layer));
|
||||
|
||||
const layerProjectRegistration = toolkitRegistration(ProjectToolkit, ProjectHandlers.layer);
|
||||
|
||||
@@ -848,6 +863,7 @@ export const layerMcpTransport = McpServer.layerHttp({
|
||||
version: packageJson.version,
|
||||
path: "/mcp",
|
||||
protocols: [McpProtocol.v2025_06_18],
|
||||
allowSessionTermination: true,
|
||||
}).pipe(Layer.provide(layerMcpAuthMiddleware));
|
||||
|
||||
export const layer = Layer.mergeAll(
|
||||
@@ -856,7 +872,7 @@ export const layer = Layer.mergeAll(
|
||||
layerThreadToolkit,
|
||||
layerAttachmentToolkit,
|
||||
layerProjectRegistration,
|
||||
layerEnvironmentRegistration,
|
||||
layerEnvironmentToolkit,
|
||||
layerPreviewControlsRegistration,
|
||||
layerWorktreeToolkitRegistration,
|
||||
layerPullRequestsToolkit,
|
||||
|
||||
@@ -57,6 +57,7 @@ import { threadShellFromProjection } from "../orchestration-v2/ProjectionStore.t
|
||||
import * as EventSink from "../orchestration-v2/EventSink.ts";
|
||||
import * as Orchestrator from "../orchestration-v2/Orchestrator.ts";
|
||||
import * as ThreadManagementService from "../orchestration-v2/ThreadManagementService.ts";
|
||||
import * as ThreadSearch from "../orchestration-v2/ThreadSearch.ts";
|
||||
import * as ProviderAdapterRegistry from "../orchestration-v2/ProviderAdapterRegistry.ts";
|
||||
import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
|
||||
import * as McpProviderSessions from "@t3tools/provider-core/server/McpProviderSessions";
|
||||
@@ -680,6 +681,7 @@ describe("orchestrator MCP toolkit", () => {
|
||||
Layer.provide(layerRegistry),
|
||||
Layer.provide(layerProviderRegistry),
|
||||
Layer.provide(layerScheduledTaskStub),
|
||||
Layer.provide(Layer.mock(ThreadSearch.ThreadSearch)({})),
|
||||
Layer.provide(
|
||||
Layer.mock(ProjectService.ProjectService)({
|
||||
getById: (id) =>
|
||||
|
||||
@@ -31,6 +31,7 @@ import * as ServerSecretStore from "../../auth/ServerSecretStore.ts";
|
||||
import * as ServerConfig from "../../config.ts";
|
||||
import * as ProviderAdapterRegistry from "../../orchestration-v2/ProviderAdapterRegistry.ts";
|
||||
import * as ThreadManagement from "../../orchestration-v2/ThreadManagementService.ts";
|
||||
import * as ThreadSearch from "../../orchestration-v2/ThreadSearch.ts";
|
||||
import * as PreviewBrowser from "../../preview/PreviewBrowser.ts";
|
||||
import * as ProjectService from "../../project/ProjectService.ts";
|
||||
import * as ProviderRegistry from "../../provider/ProviderRegistry.ts";
|
||||
@@ -69,6 +70,12 @@ import { htmlRenderFromToolItem } from "@t3tools/shared/toolOutput";
|
||||
|
||||
const decodeMcpAttachmentInput = Schema.decodeUnknownEffect(McpAttachmentInput);
|
||||
|
||||
// Registration asks for every service the thread tools declare; these cases call none that use them.
|
||||
const layerThreadToolkit = McpHttpServer.layerThreadToolkit.pipe(
|
||||
Layer.provide(Layer.mock(ThreadSearch.ThreadSearch)({})),
|
||||
Layer.provide(Layer.mock(ScheduledTaskService.ScheduledTaskService)({})),
|
||||
);
|
||||
|
||||
it("publishes unique tool names with reference-free object-root inputs", () => {
|
||||
const names = new Set<string>();
|
||||
for (const toolkit of [
|
||||
@@ -152,7 +159,7 @@ it.effect("checks capability through the production registration", () =>
|
||||
expect(result.structuredContent).toBeUndefined();
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
McpHttpServer.layerThreadToolkit.pipe(
|
||||
layerThreadToolkit.pipe(
|
||||
Layer.provideMerge(McpServer.McpServer.layer),
|
||||
Layer.provide(NodeCrypto.layer),
|
||||
Layer.provide(McpToolAccessTestkit.liveThreadsLayer),
|
||||
@@ -193,7 +200,7 @@ it.effect("returns a bounded public failure without serializing storage causes",
|
||||
expect(validate({ sequence: "invalid" }).valid).toBe(false);
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
McpHttpServer.layerThreadToolkit.pipe(
|
||||
layerThreadToolkit.pipe(
|
||||
Layer.provideMerge(McpServer.McpServer.layer),
|
||||
Layer.provide(NodeCrypto.layer),
|
||||
Layer.provide(
|
||||
@@ -308,7 +315,7 @@ it.effect("returns invalid parameter errors through the production registration"
|
||||
expect(error._tag).toBe("InvalidParams");
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
McpHttpServer.layerThreadToolkit.pipe(
|
||||
layerThreadToolkit.pipe(
|
||||
Layer.provideMerge(McpServer.McpServer.layer),
|
||||
Layer.provide(NodeCrypto.layer),
|
||||
Layer.provide(Layer.mock(ThreadManagement.ThreadManagementService)({})),
|
||||
@@ -333,7 +340,7 @@ it.effect("keeps unexpected handler defects private through the production regis
|
||||
]);
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
McpHttpServer.layerThreadToolkit.pipe(
|
||||
layerThreadToolkit.pipe(
|
||||
Layer.provideMerge(McpServer.McpServer.layer),
|
||||
Layer.provide(NodeCrypto.layer),
|
||||
Layer.provide(
|
||||
@@ -451,7 +458,7 @@ it.effect("a client caller targets any thread within its ceiling and cannot act
|
||||
expect(declaredFailure(forked)).toMatchObject({ code: "target_required" });
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
McpHttpServer.layerThreadToolkit.pipe(
|
||||
layerThreadToolkit.pipe(
|
||||
Layer.provideMerge(McpServer.McpServer.layer),
|
||||
Layer.provide(NodeCrypto.layer),
|
||||
Layer.provide(
|
||||
@@ -511,7 +518,7 @@ it.effect("a read-only client reads threads and is refused every write before it
|
||||
expect(dispatched).toEqual([]);
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
McpHttpServer.layerThreadToolkit.pipe(
|
||||
layerThreadToolkit.pipe(
|
||||
Layer.provideMerge(McpServer.McpServer.layer),
|
||||
Layer.provide(NodeCrypto.layer),
|
||||
Layer.provide(
|
||||
|
||||
@@ -12,11 +12,13 @@ import * as Fiber from "effect/Fiber";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Ref from "effect/Ref";
|
||||
import * as Stream from "effect/Stream";
|
||||
import { McpSchema, McpServer } from "effect/ai";
|
||||
|
||||
import * as Environment from "../../../environment/ServerEnvironment.ts";
|
||||
import * as ThreadCommandExecutor from "../../../orchestration-v2/ThreadCommandExecutor.ts";
|
||||
import * as ThreadManagement from "../../../orchestration-v2/ThreadManagementService.ts";
|
||||
import * as Settings from "../../../serverSettings.ts";
|
||||
import * as McpHttpServer from "../../McpHttpServer.ts";
|
||||
import * as McpInvocationContext from "../../McpInvocationContext.ts";
|
||||
import * as McpToolAccess from "../../McpToolAccess.ts";
|
||||
import { liveThreadShell } from "../../McpToolAccess.testkit.ts";
|
||||
@@ -25,6 +27,71 @@ import { EnvironmentToolkit } from "./tools.ts";
|
||||
|
||||
const environmentId = EnvironmentId.make("environment:preferences");
|
||||
const threadId = ThreadId.make("thread:preferences");
|
||||
const caller: McpInvocationContext.McpInvocationScope = {
|
||||
environmentId,
|
||||
requestNamespace: "provider:preferences",
|
||||
thread: {
|
||||
threadId,
|
||||
providerSessionId: "provider:preferences",
|
||||
providerInstanceId: ProviderInstanceId.make("codex"),
|
||||
},
|
||||
client: undefined,
|
||||
capabilities: new Set(["orchestration" as const]),
|
||||
issuedAt: 0,
|
||||
};
|
||||
const layerEnvironment = Layer.mock(Environment.ServerEnvironment)({
|
||||
getDescriptor: Effect.succeed({
|
||||
environmentId,
|
||||
label: "Test",
|
||||
platform: { os: "linux", arch: "x64" },
|
||||
serverVersion: "0.0.0",
|
||||
capabilities: { repositoryIdentity: false },
|
||||
}),
|
||||
});
|
||||
|
||||
it.effect("updates preferences for a thread caller through the /mcp registration", () =>
|
||||
Effect.gen(function* () {
|
||||
const server = yield* McpServer.McpServer;
|
||||
const result = yield* server
|
||||
.callTool({
|
||||
name: "t3_environment_preferences_update",
|
||||
arguments: { newWorktreesStartFromOrigin: true },
|
||||
})
|
||||
.pipe(
|
||||
Effect.provideService(McpInvocationContext.McpInvocationContext, caller),
|
||||
Effect.provideService(
|
||||
McpSchema.McpServerClient,
|
||||
McpSchema.McpServerClient.of({
|
||||
clientId: 1,
|
||||
protocolVersion: "2025-06-18",
|
||||
clientCapabilities: {},
|
||||
clientInfo: { name: "preferences", version: "1" },
|
||||
initializePayload: {
|
||||
protocolVersion: "2025-06-18",
|
||||
capabilities: {},
|
||||
clientInfo: { name: "preferences", version: "1" },
|
||||
},
|
||||
getClient: Effect.die("unused"),
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.structuredContent).toMatchObject({ newWorktreesStartFromOrigin: true });
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
McpHttpServer.layerEnvironmentToolkit.pipe(
|
||||
Layer.provideMerge(McpServer.McpServer.layer),
|
||||
Layer.provide(
|
||||
Layer.mock(ThreadManagement.ThreadManagementService)({
|
||||
getThreadShell: (id) => Effect.succeed(liveThreadShell(id)),
|
||||
}),
|
||||
),
|
||||
Layer.provide(layerEnvironment),
|
||||
Layer.provide(Settings.layerTest()),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
it.effect("refuses a preferences update when the caller's turn ends while it waits", () =>
|
||||
Effect.gen(function* () {
|
||||
|
||||
@@ -22,6 +22,13 @@ import * as ScheduledTaskService from "../../../scheduledTasks/ScheduledTaskServ
|
||||
import * as SecretRequests from "../../../secrets/SecretRequests.ts";
|
||||
import * as ServerSettings from "../../../serverSettings.ts";
|
||||
import * as VcsStatusBroadcaster from "../../../vcs/VcsStatusBroadcaster.ts";
|
||||
import * as ServerSecretStore from "../../../auth/ServerSecretStore.ts";
|
||||
import * as ManagedProjectFolders from "../../../project/ManagedProjectFolders.ts";
|
||||
import * as ThreadLaunchService from "../../../orchestration-v2/ThreadLaunchService.ts";
|
||||
import * as ThreadSearch from "../../../orchestration-v2/ThreadSearch.ts";
|
||||
import * as PreviewManager from "../../../preview/Manager.ts";
|
||||
import * as SourceControlRepositoryService from "../../../sourceControl/SourceControlRepositoryService.ts";
|
||||
import * as GitVcsDriver from "../../../vcs/GitVcsDriver.ts";
|
||||
import * as McpHttpServer from "../../McpHttpServer.ts";
|
||||
import * as McpSessionRegistry from "../../McpSessionRegistry.ts";
|
||||
import * as PreviewAutomationBroker from "../../PreviewAutomationBroker.ts";
|
||||
@@ -41,6 +48,13 @@ const layerStubServices = Layer.mergeAll(
|
||||
Layer.mock(GitWorkflowService.GitWorkflowService)({}),
|
||||
Layer.mock(ProjectSetupScriptRunner.ProjectSetupScriptRunner)({}),
|
||||
Layer.mock(VcsStatusBroadcaster.VcsStatusBroadcaster)({}),
|
||||
Layer.mock(GitVcsDriver.GitVcsDriver)({}),
|
||||
Layer.mock(ManagedProjectFolders.ManagedProjectFolders)({ namedProjectsRoot: "/unused" }),
|
||||
Layer.mock(PreviewManager.PreviewManager)({}),
|
||||
Layer.mock(ServerSecretStore.ServerSecretStore)({}),
|
||||
Layer.mock(SourceControlRepositoryService.SourceControlRepositoryService)({}),
|
||||
Layer.mock(ThreadLaunchService.ThreadLaunchService)({}),
|
||||
Layer.mock(ThreadSearch.ThreadSearch)({}),
|
||||
);
|
||||
|
||||
const ToolsListPayload = Schema.fromJsonString(
|
||||
|
||||
@@ -72,7 +72,7 @@ const rpcSpans = (ended: ReadonlyArray<Tracer.NativeSpan>) =>
|
||||
// RpcTest keeps Effect's own RpcServer/RpcClient spans, which ws.ts turns off with
|
||||
// `disableTracing: true`. Everything else comes from the middleware or the handlers.
|
||||
const appSpans = (ended: ReadonlyArray<Tracer.NativeSpan>) =>
|
||||
ended.filter((span) => !/^Rpc(Server|Client)\./.test(span.name));
|
||||
ended.filter((span) => span.attributes.get("rpc.system.name") !== "effect_rpc");
|
||||
|
||||
const exitTag = (span: Tracer.NativeSpan | undefined) =>
|
||||
span?.status._tag === "Ended" ? span.status.exit._tag : undefined;
|
||||
|
||||
@@ -2354,14 +2354,15 @@ it.layer(layerTest)("orchestration V2 foundation persistence", (it) => {
|
||||
it.effect("does not emit a SQL span for an empty safety claim", () =>
|
||||
Effect.gen(function* () {
|
||||
const outbox = yield* EffectOutbox.EffectOutboxV2;
|
||||
const spans: Array<string> = [];
|
||||
const statements: Array<unknown> = [];
|
||||
const tracer = Tracer.make({
|
||||
span: (options) => {
|
||||
const span = new Tracer.NativeSpan(options);
|
||||
const end = span.end.bind(span);
|
||||
span.end = (endTime, exit) => {
|
||||
end(endTime, exit);
|
||||
spans.push(span.name);
|
||||
const query = span.attributes.get("db.query.text");
|
||||
if (query !== undefined) statements.push(query);
|
||||
};
|
||||
return span;
|
||||
},
|
||||
@@ -2372,7 +2373,7 @@ it.layer(layerTest)("orchestration V2 foundation persistence", (it) => {
|
||||
.pipe(Effect.withTracer(tracer));
|
||||
|
||||
assert.isTrue(Option.isNone(claim));
|
||||
assert.notInclude(spans, "sql.execute");
|
||||
assert.deepEqual(statements, []);
|
||||
}).pipe(Effect.provide(Layer.fresh(layerEffectOutboxProvided))),
|
||||
);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ For example:
|
||||
|
||||
```apl
|
||||
['t3-code-relay-traces-prod']
|
||||
| where name startswith 'http.server'
|
||||
| where kind == 'server'
|
||||
| extend endpoint = column_ifexists('attributes.http.route', ''),
|
||||
customAttributes = column_ifexists('attributes.custom', dynamic({}))
|
||||
| project _time, name, trace_id, duration,
|
||||
|
||||
@@ -600,7 +600,7 @@ describe("HookForwarder", () => {
|
||||
expect(serialized).not.toContain("also-secret");
|
||||
expect(serialized).not.toContain("header-secret");
|
||||
const server = spans.find((span) => span.kind === "server");
|
||||
expect(server?.attributes.get("url.path")).toBe(`/v1/hooks/${endpointKey}/hook-1/<redacted>`);
|
||||
expect(server?.attributes.get("url.path")).toBe(`/v1/hooks/${endpointKey}/hook-1/redacted`);
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -639,7 +639,7 @@ describe("HookForwarder", () => {
|
||||
const servers = spans.filter((span) => span.kind === "server");
|
||||
expect(servers).toHaveLength(1);
|
||||
expect(servers[0]?.attributes.get("url.path")).toBe(
|
||||
`/v1/hooks/${endpointKey}/hook-1/<redacted>`,
|
||||
`/v1/hooks/${endpointKey}/hook-1/redacted`,
|
||||
);
|
||||
expect(spans.every((span) => span.traceId !== "11111111111111111111111111111111")).toBe(true);
|
||||
}),
|
||||
|
||||
@@ -76,7 +76,8 @@ export const redactRelayHookUrl = (url: string): string => {
|
||||
const path = url.split("?", 1)[0] ?? url;
|
||||
const segments = path.split("/");
|
||||
if (segments.length >= 6) {
|
||||
segments[5] = "<redacted>";
|
||||
// URL-safe, so span attributes built from the parsed URL keep it readable.
|
||||
segments[5] = "redacted";
|
||||
}
|
||||
return segments.join("/");
|
||||
};
|
||||
|
||||
@@ -1186,12 +1186,13 @@ describe("relay request tracing", () => {
|
||||
Effect.provideService(HttpServerRequest.HttpServerRequest, request),
|
||||
);
|
||||
|
||||
expect(spans.map((span) => span.name)).toEqual(["http.server POST", "relay.test.endpoint"]);
|
||||
expect(spans.map((span) => span.name)).toEqual(["POST", "relay.test.endpoint"]);
|
||||
expect(spans[0]?.kind).toBe("server");
|
||||
expect(spans[0]?.attributes.get("url.path")).toBe("/v1/mobile/devices");
|
||||
expect(spans[0]?.attributes.get("http.response.status_code")).toBe(204);
|
||||
expect(spans[0]?.attributes.get("http.request.header.authorization")).toBe("<redacted>");
|
||||
expect(spans[0]?.attributes.get("http.request.header.dpop")).toBe("<redacted>");
|
||||
// Headers are not captured at all, so credentials never reach the span.
|
||||
expect(spans[0]?.attributes.get("http.request.header.authorization")).toBeUndefined();
|
||||
expect(spans[0]?.attributes.get("http.request.header.dpop")).toBeUndefined();
|
||||
expect(Option.isNone(spans[0]!.parent)).toBe(true);
|
||||
expect(Option.getOrUndefined(spans[1]!.parent)?.spanId).toBe(spans[0]?.spanId);
|
||||
}),
|
||||
|
||||
@@ -21,7 +21,7 @@ import * as RpcSerialization from "effect/rpc/RpcSerialization";
|
||||
import * as Socket from "effect/socket/Socket";
|
||||
|
||||
import { fetchRemoteEnvironmentDescriptor } from "../environment/descriptor.ts";
|
||||
import { makeWsRpcProtocolClient } from "../rpc/protocol.ts";
|
||||
import { makeWsRpcProtocolClient, PING_TIMEOUT } from "../rpc/protocol.ts";
|
||||
import { isLegacyUpdateHandoffLoss, resolveServerUpdateProgressResult } from "../state/server.ts";
|
||||
import * as RelayEnvironmentDiscovery from "../relay/discovery.ts";
|
||||
import * as ConnectionResolver from "./resolver.ts";
|
||||
@@ -87,6 +87,7 @@ export const updateOutdatedHost = Effect.fn("clientRuntime.connection.updateOutd
|
||||
Layer.effect(
|
||||
RpcClient.Protocol,
|
||||
RpcClient.makeProtocolSocket({
|
||||
pingTimeout: PING_TIMEOUT,
|
||||
retryTransientErrors: false,
|
||||
retryPolicy: Schedule.recurs(0),
|
||||
}),
|
||||
|
||||
@@ -6,3 +6,7 @@ export const makeWsRpcProtocolClient = RpcClient.make(WsRpcGroup);
|
||||
type RpcClientFactory = typeof makeWsRpcProtocolClient;
|
||||
export type WsRpcProtocolClient =
|
||||
RpcClientFactory extends Effect.Effect<infer Client, any, any> ? Client : never;
|
||||
|
||||
// Pings go out every 5 seconds, and a server busy for a few seconds stops
|
||||
// answering them. Allow 15 seconds without any frame before dropping the socket.
|
||||
export const PING_TIMEOUT = "15 seconds";
|
||||
@@ -1085,7 +1085,7 @@ describe("RpcSessionFactory", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("tolerates two missed pong windows before closing the session", () =>
|
||||
it.effect("closes the session after 15 seconds without a frame from the server", () =>
|
||||
Effect.gen(function* () {
|
||||
const { factory, sockets } = yield* makeFactory();
|
||||
const session = yield* factory.connect(PREPARED);
|
||||
|
||||
@@ -24,7 +24,7 @@ import * as RpcClientError from "effect/rpc/RpcClientError";
|
||||
import * as RpcSerialization from "effect/rpc/RpcSerialization";
|
||||
import * as Socket from "effect/socket/Socket";
|
||||
|
||||
import { makeWsRpcProtocolClient, type WsRpcProtocolClient } from "./protocol.ts";
|
||||
import { makeWsRpcProtocolClient, PING_TIMEOUT, type WsRpcProtocolClient } from "./protocol.ts";
|
||||
import { NETWORK_BLOCKING_HINT } from "../errors/network.ts";
|
||||
import type {
|
||||
ConnectionAttemptError,
|
||||
@@ -170,7 +170,7 @@ export const make = Effect.fn("RpcSessionFactory.make")(function* (
|
||||
|
||||
const connected = yield* Deferred.make<void>();
|
||||
const disconnected = yield* Deferred.make<never, ConnectionTransientError>();
|
||||
// Set when the socket closes because pongs stopped, so the failure says so
|
||||
// Set when the socket closes because the server stopped answering, so the failure says so
|
||||
// instead of looking like the server closed the connection.
|
||||
const pingTimedOut = yield* Ref.make(false);
|
||||
const hooks = RpcClient.ConnectionHooks.of({
|
||||
@@ -201,6 +201,7 @@ export const make = Effect.fn("RpcSessionFactory.make")(function* (
|
||||
const layerProtocol = Layer.effect(
|
||||
RpcClient.Protocol,
|
||||
RpcClient.makeProtocolSocket({
|
||||
pingTimeout: PING_TIMEOUT,
|
||||
retryTransientErrors: false,
|
||||
retryPolicy: Schedule.recurs(0),
|
||||
}),
|
||||
|
||||
@@ -501,7 +501,10 @@ describe("OtelEnvironment", () => {
|
||||
),
|
||||
);
|
||||
assert.deepStrictEqual(
|
||||
resource.attributes.map((attribute) => attribute.key),
|
||||
resource.attributes
|
||||
.map((attribute) => attribute.key)
|
||||
// Effect adds these to every resource.
|
||||
.filter((key) => !key.startsWith("telemetry.sdk.")),
|
||||
[...attributes, "service.name"],
|
||||
);
|
||||
}),
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
diff --git a/dist/index.d.ts b/dist/index.d.ts
|
||||
index 530795c..237d090 100644
|
||||
index 845cb4c..24ede42 100644
|
||||
--- a/dist/index.d.ts
|
||||
+++ b/dist/index.d.ts
|
||||
@@ -7,14 +7,14 @@ import type * as Effect from "effect/Effect";
|
||||
@@ -10,14 +10,14 @@ import type * as Effect from "effect/Effect";
|
||||
import type * as Layer from "effect/Layer";
|
||||
import type * as Schema from "effect/Schema";
|
||||
import type * as Scope from "effect/Scope";
|
||||
@@ -17,10 +17,10 @@ index 530795c..237d090 100644
|
||||
-export * from "vitest";
|
||||
+export * from "vite-plus/test";
|
||||
/**
|
||||
* @stability unstable
|
||||
* @since 4.0.0
|
||||
* Vitest test API without additional fixtures.
|
||||
*
|
||||
diff --git a/dist/index.js b/dist/index.js
|
||||
index 740429f..b5c69b8 100644
|
||||
index 178cc74..9289296 100644
|
||||
--- a/dist/index.js
|
||||
+++ b/dist/index.js
|
||||
@@ -5,7 +5,7 @@ import * as internal from "./internal/internal.js";
|
||||
@@ -30,8 +30,8 @@ index 740429f..b5c69b8 100644
|
||||
-export * from "vitest";
|
||||
+export * from "vite-plus/test";
|
||||
/**
|
||||
* @since 4.0.0
|
||||
*/
|
||||
* Invokes the Effect Vitest equality-tester registration hook.
|
||||
*
|
||||
diff --git a/dist/internal/internal.js b/dist/internal/internal.js
|
||||
index 7138319..4092c67 100644
|
||||
--- a/dist/internal/internal.js
|
||||
@@ -46,7 +46,7 @@ index 7138319..4092c67 100644
|
||||
const runPromise = /*#__PURE__*/Effect.fnUntraced(function* (effect, _ctx) {
|
||||
const exit = yield* Effect.exit(effect);
|
||||
diff --git a/dist/utils.js b/dist/utils.js
|
||||
index 75a243d..08a4c89 100644
|
||||
index b97edbe..7dfd64a 100644
|
||||
--- a/dist/utils.js
|
||||
+++ b/dist/utils.js
|
||||
@@ -4,7 +4,7 @@ import * as Option from "effect/Option";
|
||||
@@ -59,7 +59,7 @@ index 75a243d..08a4c89 100644
|
||||
// Primitives
|
||||
// ----------------------------
|
||||
diff --git a/package.json b/package.json
|
||||
index d64c43d..939548e 100644
|
||||
index 7dbb505..38d13cb 100644
|
||||
--- a/package.json
|
||||
+++ b/package.json
|
||||
@@ -37,7 +37,6 @@
|
||||
@@ -67,14 +67,14 @@ index d64c43d..939548e 100644
|
||||
},
|
||||
"peerDependencies": {
|
||||
- "vitest": ">=5.0.0 <6.0.0",
|
||||
"effect": "^4.0.1"
|
||||
"effect": "^4.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
diff --git a/src/index.ts b/src/index.ts
|
||||
index 20c0497..2b16d32 100644
|
||||
index 9d65132..4aadda8 100644
|
||||
--- a/src/index.ts
|
||||
+++ b/src/index.ts
|
||||
@@ -7,7 +7,7 @@ import type * as Effect from "effect/Effect"
|
||||
@@ -10,7 +10,7 @@ import type * as Effect from "effect/Effect"
|
||||
import type * as Layer from "effect/Layer"
|
||||
import type * as Schema from "effect/Schema"
|
||||
import type * as Scope from "effect/Scope"
|
||||
@@ -83,7 +83,7 @@ index 20c0497..2b16d32 100644
|
||||
import * as internal from "./internal/internal.ts"
|
||||
|
||||
/**
|
||||
@@ -16,7 +16,7 @@ import * as internal from "./internal/internal.ts"
|
||||
@@ -19,7 +19,7 @@ import * as internal from "./internal/internal.ts"
|
||||
* @stability unstable
|
||||
* @since 4.0.0
|
||||
*/
|
||||
@@ -91,7 +91,7 @@ index 20c0497..2b16d32 100644
|
||||
+export * from "vite-plus/test"
|
||||
|
||||
/**
|
||||
* @stability unstable
|
||||
* Vitest test API without additional fixtures.
|
||||
diff --git a/src/internal/internal.ts b/src/internal/internal.ts
|
||||
index b43385b..4da79fd 100644
|
||||
--- a/src/internal/internal.ts
|
||||
@@ -106,10 +106,10 @@ index b43385b..4da79fd 100644
|
||||
|
||||
const getCurrentSuite = V.TestRunner.getCurrentSuite
|
||||
diff --git a/src/utils.ts b/src/utils.ts
|
||||
index 8ce3409..259be29 100644
|
||||
index 4473632..2d04404 100644
|
||||
--- a/src/utils.ts
|
||||
+++ b/src/utils.ts
|
||||
@@ -16,7 +16,7 @@ import * as Option from "effect/Option"
|
||||
@@ -17,7 +17,7 @@ import * as Option from "effect/Option"
|
||||
import * as Predicate from "effect/Predicate"
|
||||
import * as Result from "effect/Result"
|
||||
import * as assert from "node:assert"
|
||||
@@ -1,139 +0,0 @@
|
||||
diff --git a/dist/ai/McpServer.js b/dist/ai/McpServer.js
|
||||
index 2da594107273980144e84ab9b53636ef34043f6b..9fada51944f58fd0d988ae8f6b18f83e79583a25 100644
|
||||
--- a/dist/ai/McpServer.js
|
||||
+++ b/dist/ai/McpServer.js
|
||||
@@ -1093,7 +1093,7 @@ export const layerHttp = options => {
|
||||
const methodNotAllowed = request => isAllowedMcpOrigin(request, options.allowedOrigins) ? Effect.succeed(methodNotAllowedResponse) : Effect.succeed(HttpServerResponse.empty({
|
||||
status: 403
|
||||
}));
|
||||
- const routes = Layer.mergeAll(HttpRouter.add("GET", options.path, methodNotAllowed), HttpRouter.add("PUT", options.path, methodNotAllowed), HttpRouter.add("PATCH", options.path, methodNotAllowed), HttpRouter.add("DELETE", options.path, methodNotAllowed), HttpRouter.add("OPTIONS", options.path, methodNotAllowed));
|
||||
+ const routes = Layer.mergeAll(HttpRouter.add("GET", options.path, methodNotAllowed), HttpRouter.add("PUT", options.path, methodNotAllowed), HttpRouter.add("PATCH", options.path, methodNotAllowed), HttpRouter.add("OPTIONS", options.path, methodNotAllowed));
|
||||
return Layer.merge(layerWithRuntime(options, "http"), routes).pipe(Layer.provide(layerMcpProtocolHttp(options)), Layer.provide(runtime), Layer.provide(RpcSerialization.layerJsonRpc()));
|
||||
};
|
||||
const layerMcpProtocolHttp = options => Layer.effect(RpcServer.Protocol)(Effect.gen(function* () {
|
||||
@@ -1136,6 +1136,17 @@ const layerMcpProtocolHttp = options => Layer.effect(RpcServer.Protocol)(Effect.
|
||||
}))) : response;
|
||||
});
|
||||
});
|
||||
+ yield* router.add("DELETE", options.path, request => {
|
||||
+ if (!isAllowedMcpOrigin(request, options.allowedOrigins)) {
|
||||
+ return Effect.succeed(HttpServerResponse.empty({
|
||||
+ status: 403
|
||||
+ }));
|
||||
+ }
|
||||
+ const sessionId = request.headers[MCP_SESSION_ID_HEADER];
|
||||
+ return Effect.succeed(HttpServerResponse.empty({
|
||||
+ status: sessionId === undefined ? 400 : runtime.terminateSession(sessionId) ? 204 : 404
|
||||
+ }));
|
||||
+ });
|
||||
return protocol;
|
||||
}));
|
||||
const mcpHttpSerialization = /*#__PURE__*/(() => {
|
||||
diff --git a/dist/ai/internal/mcpRuntime.js b/dist/ai/internal/mcpRuntime.js
|
||||
index 06370fd1341ae7a6b681c513a3a3c2866a414b7b..baa945b8b4763b5472c4a900b90b817209caa4bf 100644
|
||||
--- a/dist/ai/internal/mcpRuntime.js
|
||||
+++ b/dist/ai/internal/mcpRuntime.js
|
||||
@@ -336,6 +336,7 @@ export const make = /*#__PURE__*/Effect.fnUntraced(function* (protocols) {
|
||||
},
|
||||
effectLogLevel: (clientId, headers, fallback) => stateful?.effectLogLevel(clientId, headers, fallback) ?? fallback,
|
||||
disconnect: clientId => stateful?.disconnect(clientId),
|
||||
+ terminateSession: sessionId => stateful?.terminateSession(sessionId) ?? false,
|
||||
deliveryClientIds: () => stateful?.initializedClientIds() ?? [],
|
||||
canDeliver: (clientId, headers, notification, fallback) => stateful?.canDeliver(clientId, headers, notification, fallback) ?? true,
|
||||
installHandlers: Effect.fnUntraced(function* (options) {
|
||||
diff --git a/dist/ai/internal/mcpStatefulRuntime.js b/dist/ai/internal/mcpStatefulRuntime.js
|
||||
index 9471bdfbcff0643b44df3a08c3701f743a299638..455860316ddfccaf98ff95f9f05da500c331869c 100644
|
||||
--- a/dist/ai/internal/mcpStatefulRuntime.js
|
||||
+++ b/dist/ai/internal/mcpStatefulRuntime.js
|
||||
@@ -46,6 +46,7 @@ export const make = () => {
|
||||
},
|
||||
resolve: resolveSession,
|
||||
resolveSessionId: sessionId => bySessionId.get(sessionId),
|
||||
+ terminateSession: sessionId => bySessionId.delete(sessionId),
|
||||
setLogLevel: (level, clientId, headers) => Effect.sync(() => {
|
||||
const session = resolveSession(clientId, headers);
|
||||
if (session !== undefined) {
|
||||
diff --git a/dist/http/HttpClientResponse.js b/dist/http/HttpClientResponse.js
|
||||
index 42fba673de3b6bdc089c305f2e87ad56c3bfc374..2b4981b8a88606fb93d62a29f21f9556803307c4 100644
|
||||
--- a/dist/http/HttpClientResponse.js
|
||||
+++ b/dist/http/HttpClientResponse.js
|
||||
@@ -195,7 +195,7 @@ class WebHttpClientResponse extends Inspectable.Class {
|
||||
if (this.cachedCookies) {
|
||||
return this.cachedCookies;
|
||||
}
|
||||
- return this.cachedCookies = Cookies.fromSetCookie(this.source.headers.getSetCookie());
|
||||
+ return this.cachedCookies = Cookies.fromSetCookie(this.source.headers.getSetCookie?.() ?? []);
|
||||
}
|
||||
get remoteAddress() {
|
||||
return Option.none();
|
||||
diff --git a/dist/rpc/RpcClient.d.ts b/dist/rpc/RpcClient.d.ts
|
||||
index c498ff74510b784dcba791dbf6b8f23dac40a71d..8be9c910a8112a5289159251846128cd27cf32aa 100644
|
||||
--- a/dist/rpc/RpcClient.d.ts
|
||||
+++ b/dist/rpc/RpcClient.d.ts
|
||||
@@ -302,6 +302,8 @@ export declare const layerProtocolWorker: (options: {
|
||||
declare const ConnectionHooks_base: Context.ServiceClass<ConnectionHooks, "effect/rpc/RpcClient/ConnectionHooks", {
|
||||
readonly onConnect: Effect.Effect<void>;
|
||||
readonly onDisconnect: Effect.Effect<void>;
|
||||
+ /** Runs when the socket is dropped because pongs stopped, before `onDisconnect`. */
|
||||
+ readonly onPingTimeout?: Effect.Effect<void> | undefined;
|
||||
}>;
|
||||
/**
|
||||
* Represents optional client protocol hooks that run when a transport connects
|
||||
diff --git a/dist/rpc/RpcClient.js b/dist/rpc/RpcClient.js
|
||||
index 8af2e2efa9311d582add61fef131fd39fd459ab4..723649f05baa61ac33c9bc3634d106caa9641164 100644
|
||||
--- a/dist/rpc/RpcClient.js
|
||||
+++ b/dist/rpc/RpcClient.js
|
||||
@@ -679,11 +679,11 @@ export const makeProtocolSocket = options => Protocol.make(Effect.fnUntraced(fun
|
||||
yield* processData(frames[i]);
|
||||
}
|
||||
}
|
||||
- }).pipe(Effect.scoped, Effect.raceFirst(Effect.flatMap(pinger.timeout, () => Effect.fail(new Socket.SocketError({
|
||||
+ }).pipe(Effect.scoped, Effect.raceFirst(Effect.flatMap(pinger.timeout, () => (Option.isSome(hooks) && hooks.value.onPingTimeout ? hooks.value.onPingTimeout : Effect.void).pipe(Effect.andThen(Effect.fail(new Socket.SocketError({
|
||||
reason: new Socket.SocketReadError({
|
||||
cause: new Error("ping timeout")
|
||||
})
|
||||
- })))));
|
||||
+ })))))));
|
||||
}).pipe(Option.isSome(hooks) ? Effect.ensuring(hooks.value.onDisconnect) : identity, Effect.tapCause(cause => {
|
||||
const error = Cause.findError(cause);
|
||||
const hasError = Result.isSuccess(error);
|
||||
@@ -726,17 +726,25 @@ export const makeProtocolSocket = options => Protocol.make(Effect.fnUntraced(fun
|
||||
const defaultRetryPolicy = /*#__PURE__*/Schedule.min([/*#__PURE__*/Schedule.exponential(500, 1.5), /*#__PURE__*/Schedule.spaced(5000)]);
|
||||
const makePinger = /*#__PURE__*/Effect.fnUntraced(function* (writePing) {
|
||||
let recievedPong = true;
|
||||
+ let missedPongs = 0;
|
||||
const latch = Latch.makeUnsafe();
|
||||
const reset = () => {
|
||||
recievedPong = true;
|
||||
+ missedPongs = 0;
|
||||
latch.closeUnsafe();
|
||||
};
|
||||
const onPong = () => {
|
||||
recievedPong = true;
|
||||
+ missedPongs = 0;
|
||||
};
|
||||
yield* Effect.suspend(() => {
|
||||
- if (!recievedPong) return latch.open;
|
||||
+ if (!recievedPong) {
|
||||
+ missedPongs += 1;
|
||||
+ if (missedPongs >= 3) return latch.open;
|
||||
+ return writePing;
|
||||
+ }
|
||||
recievedPong = false;
|
||||
+ missedPongs = 0;
|
||||
return writePing;
|
||||
}).pipe(Effect.delay("5 seconds"), Effect.ignore, Effect.forever, Effect.interruptible, Effect.forkScoped);
|
||||
return {
|
||||
diff --git a/src/http/HttpClientResponse.ts b/src/http/HttpClientResponse.ts
|
||||
index c037015185da1e0c664653b5a496832a9449f3c1..a8b0d8be28bbbd3a0d0d3f1a222c2f074d2d3ad5 100644
|
||||
--- a/src/http/HttpClientResponse.ts
|
||||
+++ b/src/http/HttpClientResponse.ts
|
||||
@@ -341,7 +341,7 @@ class WebHttpClientResponse extends Inspectable.Class implements HttpClientRespo
|
||||
if (this.cachedCookies) {
|
||||
return this.cachedCookies
|
||||
}
|
||||
- return this.cachedCookies = Cookies.fromSetCookie(this.source.headers.getSetCookie())
|
||||
+ return this.cachedCookies = Cookies.fromSetCookie(this.source.headers.getSetCookie?.() ?? [])
|
||||
}
|
||||
|
||||
get remoteAddress(): Option.Option<string> {
|
||||
@@ -0,0 +1,31 @@
|
||||
diff --git a/dist/rpc/RpcClient.d.ts b/dist/rpc/RpcClient.d.ts
|
||||
index ebfe86f..3ff235d 100644
|
||||
--- a/dist/rpc/RpcClient.d.ts
|
||||
+++ b/dist/rpc/RpcClient.d.ts
|
||||
@@ -320,6 +320,8 @@ export declare const layerProtocolWorker: (options: {
|
||||
declare const ConnectionHooks_base: Context.ServiceClass<ConnectionHooks, "effect/rpc/RpcClient/ConnectionHooks", {
|
||||
readonly onConnect: Effect.Effect<void>;
|
||||
readonly onDisconnect: Effect.Effect<void>;
|
||||
+ /** Runs when the socket is dropped because the server stopped answering, before `onDisconnect`. */
|
||||
+ readonly onPingTimeout?: Effect.Effect<void> | undefined;
|
||||
}>;
|
||||
/**
|
||||
* Represents optional client protocol hooks that run when a transport connects
|
||||
diff --git a/dist/rpc/RpcClient.js b/dist/rpc/RpcClient.js
|
||||
index f5b14ef..cccf0a4 100644
|
||||
--- a/dist/rpc/RpcClient.js
|
||||
+++ b/dist/rpc/RpcClient.js
|
||||
@@ -688,11 +688,11 @@ export const makeProtocolSocket = options => Protocol.make(Effect.fnUntraced(fun
|
||||
yield* processData(frames[i]);
|
||||
}
|
||||
}
|
||||
- }).pipe(Effect.scoped, Effect.raceFirst(Effect.flatMap(pinger.timeout, () => Effect.fail(new Socket.SocketError({
|
||||
+ }).pipe(Effect.scoped, Effect.raceFirst(Effect.flatMap(pinger.timeout, () => (Option.isSome(hooks) && hooks.value.onPingTimeout ? hooks.value.onPingTimeout : Effect.void).pipe(Effect.andThen(Effect.fail(new Socket.SocketError({
|
||||
reason: new Socket.SocketReadError({
|
||||
cause: new Error("ping timeout")
|
||||
})
|
||||
- })))));
|
||||
+ })))))));
|
||||
}).pipe(Option.isSome(hooks) ? Effect.ensuring(hooks.value.onDisconnect) : identity, Effect.tapCause(cause => {
|
||||
const error = Cause.findError(cause);
|
||||
const hasError = Result.isSuccess(error);
|
||||
Generated
+328
-327
File diff suppressed because it is too large.
Load diff
+20
-18
@@ -30,14 +30,14 @@ catalog:
|
||||
"@clerk/expo": 4.6.8
|
||||
"@clerk/react": 6.16.1
|
||||
"@clerk/shared": 4.33.0
|
||||
"@effect/atom-react": 4.0.1
|
||||
"@effect/openapi-generator": 4.0.1
|
||||
"@effect/platform-node": 4.0.1
|
||||
"@effect/platform-node-shared": 4.0.1
|
||||
"@effect/sql-pg": 4.0.1
|
||||
"@effect/sql-sqlite-do": 4.0.1
|
||||
"@effect/atom-react": 4.0.2
|
||||
"@effect/openapi-generator": 4.0.2
|
||||
"@effect/platform-node": 4.0.2
|
||||
"@effect/platform-node-shared": 4.0.2
|
||||
"@effect/sql-pg": 4.0.2
|
||||
"@effect/sql-sqlite-do": 4.0.2
|
||||
"@effect/tsgo": 0.46.1
|
||||
"@effect/vitest": 4.0.1
|
||||
"@effect/vitest": 4.0.2
|
||||
"@legendapp/list": 3.3.5
|
||||
"@noble/curves": 1.9.1
|
||||
"@noble/hashes": 1.8.0
|
||||
@@ -46,7 +46,8 @@ catalog:
|
||||
"@tailwindcss/oxide": 4.3.3
|
||||
"@tailwindcss/vite": 4.3.3
|
||||
"@types/node": 24.12.4
|
||||
effect: 4.0.1
|
||||
"@types/ws": 8.18.2
|
||||
effect: 4.0.2
|
||||
jose: 6.2.2
|
||||
lightningcss: 1.33.0
|
||||
tailwindcss: 4.3.3
|
||||
@@ -86,15 +87,15 @@ minimumReleaseAgeExclude:
|
||||
- "@distilled.cloud/[email protected]"
|
||||
- "@distilled.cloud/[email protected]"
|
||||
- "@distilled.cloud/[email protected]"
|
||||
- "@effect/[email protected].1"
|
||||
- "@effect/[email protected].1"
|
||||
- "@effect/[email protected].1"
|
||||
- "@effect/[email protected].1"
|
||||
- "@effect/[email protected].1"
|
||||
- "@effect/[email protected].1"
|
||||
- "@effect/[email protected].1"
|
||||
- "@effect/[email protected].2"
|
||||
- "@effect/[email protected].2"
|
||||
- "@effect/[email protected].2"
|
||||
- "@effect/[email protected].2"
|
||||
- "@effect/[email protected].2"
|
||||
- "@effect/[email protected].2"
|
||||
- "@effect/[email protected].2"
|
||||
- [email protected]
|
||||
- [email protected].1
|
||||
- [email protected].2
|
||||
- "@legendapp/[email protected]"
|
||||
- "@expo/[email protected]"
|
||||
- "@expo/[email protected]"
|
||||
@@ -252,6 +253,7 @@ overrides:
|
||||
tailwindcss: "catalog:"
|
||||
# Ranges from @effect/platform-node, jsdom, unifont, Expo and libsql otherwise
|
||||
# settle on two patch releases of each major. Older majors stay as they are.
|
||||
"@types/ws@^8": "catalog:"
|
||||
"undici@^8": "catalog:"
|
||||
"ws@^8": "catalog:"
|
||||
vite: "catalog:"
|
||||
@@ -274,7 +276,7 @@ patchedDependencies:
|
||||
[email protected]: patches/[email protected]
|
||||
[email protected]: patches/[email protected]
|
||||
"@clerk/[email protected]": patches/@[email protected]
|
||||
"@effect/[email protected].1": patches/@[email protected].1.patch
|
||||
"@effect/[email protected].2": patches/@[email protected].2.patch
|
||||
"@expo/[email protected]": patches/@[email protected]
|
||||
[email protected]: patches/[email protected]
|
||||
[email protected]: patches/[email protected]
|
||||
@@ -290,7 +292,7 @@ patchedDependencies:
|
||||
"@react-native-menu/[email protected]": patches/@[email protected]
|
||||
"@react-navigation/[email protected]": patches/@react-navigation%[email protected]
|
||||
[email protected]: patches/[email protected]
|
||||
[email protected].1: patches/[email protected].1.patch
|
||||
[email protected].2: patches/[email protected].2.patch
|
||||
[email protected]: patches/[email protected]
|
||||
# Link http(s) URLs with a port or a single-label host. md4c otherwise requires a dotted host and stops at ':'.
|
||||
[email protected]: patches/[email protected]
|
||||
|
||||
Reference in new issue
Block a user