Repository navigation
fix(infra): keep the boot checks in the production web build - #399
Merged
Merged
Conversation
package.json lists the modules that have side effects, and the bundler drops a bare import of any module that is not on the list. boot.server was not on it, so the built web server ran neither validateEnv() nor the Row-Level Security guard. It started with a short or placeholder session secret, without DB_RUNTIME_URL, or as a database role that bypasses RLS: everything the self-hosting guide says it refuses. The dev server and the worker are not bundled and kept running the checks, which is why nothing noticed. boot.server is now declared, along with the worker's locale module, the other bare import of an app module. A test fails when a side-effect-only import of an app module is missing from the list. The health-monitoring guide notes what follows for probes: the web process needs the database once, at startup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The built web server runs neither
validateEnv()nor the Row-Level Security boot guard.entry.server.tsximports~/shared/infra/boot.serverfor its side effects only.package.jsonlists the modules that have side effects,boot.serveris not on that list, and the bundler drops a bare import of anything that is not. In a production build ofmain,build/servercontains no occurrence ofvalidateEnvorassertRuntimeRoleEnforcesRls, and starting it withoutUNITAE_CRON_SECRETprints no warning.So the web process started in every situation the self-hosting guide says it refuses: a session secret shorter than 32 characters or left on the placeholder, no
DB_RUNTIME_URL, a database role that is a superuser or hasBYPASSRLS. The dev server and the worker are not bundled and kept running the checks, which is why nothing noticed.Fix.
boot.serveris declared insideEffects, along with the worker's locale module, the only other bare import of an app module.Guard.
scripts/side-effect-imports.test.tsfails when a side-effect-only import of an app module is missing from the list, and names the import. It was written first and failed on the three imports above.Verified on a production build of this branch:
UNITAE_CRON_SECRETUNITAE_SESSION_SECRET is insecureDB_RUNTIME_URLRow-Level Security cannot be enforcedRow-Level Security cannot be verifieddocs/self-hosting/health-monitoring.mdnotes what follows for probes: the web process needs the database once, at startup.Upgrade impact
An instance that boots today may refuse to after this change. That is the documented behaviour, enforced for the first time in the web process. It happens when, outside
NODE_ENV=development/test:UNITAE_SESSION_SECRETis shorter than 32 characters or is the example placeholder;DB_URLis missing;DB_RUNTIME_URLis missing, or its role is a superuser or hasBYPASSRLS;Each case exits with a message naming the cause. The worker has enforced the same checks all along, so an instance whose worker starts with the same environment already passes them.
Type de changement
Checklist
pnpm build:format)Issue liée
None.