Download src/gateway/server/ws-connection/authenticated-request-dispatch.load-failure.test.ts from SaylorTwift/openclaw: direct link, hf CLI and curl.
- Browser
- Download file 2.08 kB
-
https://huggingface.co/SaylorTwift/openclaw/resolve/main/src/gateway/server/ws-connection/authenticated-request-dispatch.load-failure.test.ts
- Command line
-
hf download hf://SaylorTwift/openclaw/src/gateway/server/ws-connection/authenticated-request-dispatch.load-failure.test.ts
-
curl -L -o authenticated-request-dispatch.load-failure.test.ts https://huggingface.co/SaylorTwift/openclaw/resolve/main/src/gateway/server/ws-connection/authenticated-request-dispatch.load-failure.test.ts
2.08 kB
| import path from "node:path"; | |
| import { fileURLToPath, pathToFileURL } from "node:url"; | |
| import { afterEach, describe, expect, it, vi } from "vitest"; | |
| function moduleNotFoundError(filePath: string): Error { | |
| return Object.assign(new Error(`Cannot find module '${filePath}'`), { | |
| code: "ERR_MODULE_NOT_FOUND", | |
| url: pathToFileURL(filePath).href, | |
| }); | |
| } | |
| describe("authenticated request dispatcher load failures", () => { | |
| afterEach(() => { | |
| vi.doUnmock("./authenticated-request-dispatch.server-methods.runtime.js"); | |
| vi.resetModules(); | |
| vi.unstubAllEnvs(); | |
| }); | |
| it("returns typed restart guidance when the running install changed", async () => { | |
| vi.stubEnv("OPENCLAW_PROFILE", "r13"); | |
| const missingChunk = path.join( | |
| path.dirname(fileURLToPath(import.meta.url)), | |
| "missing-request-dispatch-chunk.js", | |
| ); | |
| const error = moduleNotFoundError(missingChunk); | |
| vi.resetModules(); | |
| vi.doMock("./authenticated-request-dispatch.server-methods.runtime.js", () => ({ | |
| get handleGatewayRequest() { | |
| throw error; | |
| }, | |
| })); | |
| // Imported after doMock so the harness binds a dispatcher whose lazy runtime | |
| // load hits the mocked failing module. | |
| const { createDispatchTestHarness, createOperatorWsClient } = | |
| await import("./authenticated-request-dispatch.test-support.js"); | |
| const harness = createDispatchTestHarness({ connId: "stale-install-dispatch" }); | |
| const client = createOperatorWsClient({ connId: "stale-install-dispatch" }); | |
| await harness.dispatcher.dispatch( | |
| { type: "req", id: "stale-install", method: "status", params: {} }, | |
| client, | |
| ); | |
| expect(await harness.awaitResponseFrame("stale-install")).toMatchObject({ | |
| id: "stale-install", | |
| ok: false, | |
| error: { | |
| code: "UNAVAILABLE", | |
| retryable: false, | |
| message: expect.stringContaining("openclaw --profile r13 gateway restart"), | |
| details: { | |
| code: "STALE_INSTALL", | |
| restartCommand: "openclaw --profile r13 gateway restart", | |
| }, | |
| }, | |
| }); | |
| }); | |
| }); | |