Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-dev-browser-sw-static-route.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@spencer-kit/coder-studio": patch
---

Fix server startup failure when bundled web assets include `dev-browser-sw.js` by excluding the service worker from static file glob registration.
20 changes: 20 additions & 0 deletions packages/server/src/app-routing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,26 @@ describe("app routing", () => {
expect(response.body).toContain("coder-studio-dev-browser-session");
});

it("does not double-register dev-browser-sw.js when it exists in the web root", async () => {
writeFileSync(join(webRoot, "dev-browser-sw.js"), 'const MARKER = "bundled-dev-browser-sw";\n');

const instance = await createApp();

const getResponse = await instance.inject({
method: "GET",
url: "/dev-browser-sw.js",
});
expect(getResponse.statusCode).toBe(200);
expect(getResponse.headers["cache-control"]).toBe("no-cache, no-store, must-revalidate");
expect(getResponse.body).toContain("bundled-dev-browser-sw");

const headResponse = await instance.inject({
method: "HEAD",
url: "/dev-browser-sw.js",
});
expect(headResponse.statusCode).toBe(200);
});

it("serves the dev browser service worker without a configured web root", async () => {
const instance = await createApp(false, {}, { webRoot: null });

Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export async function buildFastifyApp(deps: AppDeps): Promise<FastifyInstance> {
root: deps.webRoot,
prefix: "/",
wildcard: false,
globIgnore: ["index.html", "assets/**"],
globIgnore: ["index.html", "assets/**", "dev-browser-sw.js"],
maxAge: "1y",
immutable: true,
});
Expand Down
Loading