diff --git a/src/server/context.ts b/src/server/context.ts
index 5696848e..73279197 100644
--- a/src/server/context.ts
+++ b/src/server/context.ts
@@ -56,6 +56,11 @@ function isObject(value: unknown) {
value !== null;
}
+function isDevMode() {
+ // Env var is only set in prod (on Deploy).
+ return Deno.env.get("DENO_DEPLOYMENT_ID") === undefined;
+}
+
interface StaticFile {
/** The URL to the static file on disk. */
localUrl: URL;
@@ -94,6 +99,7 @@ export class ServerContext {
plugins: Plugin[],
configPath: string,
jsxConfig: JSXConfig,
+ dev: boolean = isDevMode(),
) {
this.#routes = routes;
this.#islands = islands;
@@ -104,7 +110,7 @@ export class ServerContext {
this.#notFound = notFound;
this.#error = error;
this.#plugins = plugins;
- this.#dev = typeof Deno.env.get("DENO_DEPLOYMENT_ID") !== "string"; // Env var is only set in prod (on Deploy).
+ this.#dev = dev;
this.#builder = new EsbuildBuilder({
buildID: BUILD_ID,
entrypoints: collectEntrypoints(this.#dev, this.#islands, this.#plugins),
@@ -320,6 +326,12 @@ export class ServerContext {
}
}
+ const dev = isDevMode();
+ if (dev) {
+ // Ensure that debugging hooks are set up for SSR rendering
+ await import("preact/debug");
+ }
+
return new ServerContext(
routes,
islands,
@@ -332,6 +344,7 @@ export class ServerContext {
opts.plugins ?? [],
configPath,
jsxConfig,
+ dev,
);
}
diff --git a/src/server/default_error_page.ts b/src/server/default_error_page.ts
index 2f54f2b1..e5f22c0a 100644
--- a/src/server/default_error_page.ts
+++ b/src/server/default_error_page.ts
@@ -17,6 +17,7 @@ export default function DefaultErrorPage(props: ErrorPageProps) {
return h(
"div",
{
+ class: "frsh-error-page",
style: {
display: "flex",
justifyContent: "center",
diff --git a/tests/fixture_render_error/deno.json b/tests/fixture_render_error/deno.json
new file mode 100644
index 00000000..5a3c9a8c
--- /dev/null
+++ b/tests/fixture_render_error/deno.json
@@ -0,0 +1,13 @@
+{
+ "lock": false,
+ "imports": {
+ "$fresh/": "../../",
+ "preact": "https://esm.sh/preact@10.15.1",
+ "preact/": "https://esm.sh/preact@10.15.1/",
+ "preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.0.3"
+ },
+ "compilerOptions": {
+ "jsx": "react-jsx",
+ "jsxImportSource": "preact"
+ }
+}
diff --git a/tests/fixture_render_error/dev.ts b/tests/fixture_render_error/dev.ts
new file mode 100755
index 00000000..2d85d6c1
--- /dev/null
+++ b/tests/fixture_render_error/dev.ts
@@ -0,0 +1,5 @@
+#!/usr/bin/env -S deno run -A --watch=static/,routes/
+
+import dev from "$fresh/dev.ts";
+
+await dev(import.meta.url, "./main.ts");
diff --git a/tests/fixture_render_error/fresh.gen.ts b/tests/fixture_render_error/fresh.gen.ts
new file mode 100644
index 00000000..799a93fb
--- /dev/null
+++ b/tests/fixture_render_error/fresh.gen.ts
@@ -0,0 +1,15 @@
+// DO NOT EDIT. This file is generated by fresh.
+// This file SHOULD be checked into source version control.
+// This file is automatically updated during development when running `dev.ts`.
+
+import * as $0 from "./routes/index.tsx";
+
+const manifest = {
+ routes: {
+ "./routes/index.tsx": $0,
+ },
+ islands: {},
+ baseUrl: import.meta.url,
+};
+
+export default manifest;
diff --git a/tests/fixture_render_error/main.ts b/tests/fixture_render_error/main.ts
new file mode 100644
index 00000000..dedce9cb
--- /dev/null
+++ b/tests/fixture_render_error/main.ts
@@ -0,0 +1,10 @@
+///