Skip to content

Commit 02b1763

Browse files
committed
test: build server function with unused try catch variable
1 parent 8e3536e commit 02b1763

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

apps/tests/src/e2e/server-function.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,11 @@ test.describe("server-function", () => {
9191
await page.goto("http://localhost:3000/server-env");
9292
await expect(page.locator("#server-fn-test")).toContainText('{"result":true}');
9393
});
94+
95+
test("should build with a server function including an unused try/catch variable", async ({
96+
page,
97+
}) => {
98+
await page.goto("http://localhost:3000/server-function-unused-trycatch");
99+
await expect(page.locator("#server-fn-test")).toContainText("false");
100+
});
94101
});
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { createEffect, createSignal } from "solid-js";
2+
3+
function serverFnTryCatch() {
4+
"use server";
5+
6+
try {
7+
throw new Error();
8+
} catch (error) {
9+
return false;
10+
}
11+
}
12+
13+
export default function App() {
14+
const [output, setOutput] = createSignal<boolean>();
15+
16+
createEffect(async () => {
17+
const result = await serverFnTryCatch();
18+
setOutput(result);
19+
});
20+
21+
return (
22+
<main>
23+
<span id="server-fn-test">{JSON.stringify(output())}</span>
24+
</main>
25+
);
26+
}

0 commit comments

Comments
 (0)