Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): explain root browser launch failures instead of pointing to setup #19846

Mergedmxdhavgautam(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/19846/headmerged by juliusmarminge View on GitHub

Showing 5 changed files with 59 additions and 4 deletions (loading 2).

x
0 of 5 viewed, 5 left
30 additions and 0 deletionsapps/server/src/cli/browser.test.tsAdded
View file
@@ -0,0 +1,30 @@
+import * as NodeServices from "@effect/platform-node/NodeServices";
+import { expect, it } from "@effect/vitest";
+import * as HostProcess from "@t3tools/shared/HostProcess";
+import * as Effect from "effect/Effect";
+import * as FileSystem from "effect/FileSystem";
+import * as Layer from "effect/Layer";
+import * as TestConsole from "effect/testing/TestConsole";
+import { Command } from "effect/cli";
+​
+import { browserCommand } from "./browser.ts";
+​
+it.effect("setup in a root shell warns that the server cannot run as root", () =>
+ Effect.gen(function* () {
+ // Every file read fails, so setup finds nothing to install and changes nothing.
+ yield* Command.runWith(browserCommand, { version: "0.0.0" })([
+ "setup",
+ "--base-dir",
+ "/nonexistent",
+ ]).pipe(
+ Effect.provide(FileSystem.layerNoop({})),
+ Effect.provideService(HostProcess.Platform, "linux"),
+ Effect.provideService(HostProcess.UserId, 0),
+ // A root user who follows the old advice runs setup through sudo.
+ Effect.provideService(HostProcess.Environment, { SUDO_USER: "root" }),
+ );
+ const output = (yield* TestConsole.logLines).join("\n");
+ expect(output).toContain("Chrome will not start its sandbox as root");
+ expect(output).not.toContain("ready");
+ }).pipe(Effect.provide(Layer.mergeAll(NodeServices.layer, TestConsole.layer))),
+);