Cover cyclic error payload fallback safety in renderer diagnostics
Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
1 parent
07a775c03f
commit
ec402cfb24
1 file changed
+26
@@ -253,6 +253,20 @@ describe("wsNativeApi", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("falls back safely when send throw payload contains cyclic error references", async () => {
|
||||
setWindowSearch("?ws=ws%3A%2F%2F127.0.0.1%3A4520");
|
||||
MockWebSocket.failSend = true;
|
||||
const cyclicError: { error?: unknown } = {};
|
||||
cyclicError.error = cyclicError;
|
||||
MockWebSocket.failSendError = cyclicError;
|
||||
const { getOrCreateWsNativeApi } = await import("./wsNativeApi");
|
||||
const api = getOrCreateWsNativeApi();
|
||||
|
||||
await expect(api.todos.list()).rejects.toThrow(
|
||||
"Failed to send runtime request 'todos.list': unknown websocket failure",
|
||||
);
|
||||
});
|
||||
|
||||
it("recovers after a transient websocket send failure", async () => {
|
||||
setWindowSearch("?ws=ws%3A%2F%2F127.0.0.1%3A4480");
|
||||
MockWebSocket.failSend = true;
|
||||
@@ -2315,6 +2329,18 @@ describe("wsNativeApi", () => {
|
||||
await expect(api.todos.list()).rejects.toThrow("Failed to connect to local t3 runtime.");
|
||||
});
|
||||
|
||||
it("falls back safely when constructor throw payload contains cyclic error references", async () => {
|
||||
setWindowSearch("?ws=ws%3A%2F%2F127.0.0.1%3A4521");
|
||||
MockWebSocket.failConstruct = true;
|
||||
const cyclicError: { error?: unknown } = {};
|
||||
cyclicError.error = cyclicError;
|
||||
MockWebSocket.failConstructError = cyclicError;
|
||||
const { getOrCreateWsNativeApi } = await import("./wsNativeApi");
|
||||
const api = getOrCreateWsNativeApi();
|
||||
|
||||
await expect(api.todos.list()).rejects.toThrow("Failed to connect to local t3 runtime.");
|
||||
});
|
||||
|
||||
it("recovers after websocket construction failure on next request", async () => {
|
||||
setWindowSearch("?ws=ws%3A%2F%2F127.0.0.1%3A4427");
|
||||
MockWebSocket.failConstruct = true;
|
||||
|
||||
Reference in new issue
Block a user