mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#231
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Romuromylus on GitHub (May 7, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/510
Summary
After PR #507, the server crash-loops at startup with
ReferenceError: Cannot access 'sharedLogger' before initializationwheneverensureEnvFileExists()fails to write the auto-created.envfile (e.g. read-only filesystem, or a Docker user that lacks write permission to the monorepo root).Expected behavior
Per the comment in
ensureEnvFileExists(): "The write is best-effort: read-only filesystems (some Docker images, locked-down installs) silently fall back to 'no .env' mode, which dotenv handles the same as today." Startup should continue without.env, optionally with a warning.Actual behavior
writeFileSyncthrows (e.g.EACCES), the catch triessharedLogger.warn(...), andsharedLoggeris in TDZ. The originalEACCESis masked by aReferenceErrorand Node exits 1 in a tight loop (Docker/Swarm restarts forever).Why TDZ
runtime-config.tsandlib/logger.tsform an import cycle:runtime-config.tsimportssharedLoggerfromlib/logger.jslib/logger.tsimportsgetLogLevel/getNodeEnvfromconfig/runtime-config.jspackages/server/src/index.tsimportslib/logger.jsfirst (line 7), thenconfig/runtime-config.js(line 8), so the cycle enters throughlogger.ts. Whilelogger.tsis still mid-evaluation,runtime-config.tsruns to its bottom and hits the top-levelloadRuntimeEnv()call. IfensureEnvFileExists'swriteFileSyncthrows, the catch referencessharedLogger— butlogger.tshasn't yet executedexport const logger = pino(...), so the import binding is uninitialized.The function declarations on
runtime-config.tswork across the cycle (hoisted in linking phase), which is whygetLogLevel/getNodeEnvsurvive — butconst/letexports likeloggerdo not.Steps to reproduce
nodeuser cannot write/app/.env, sowriteFileSyncthrowsEACCES.Reproduces deterministically on EasyPanel / Docker Swarm with the upstream Dockerfile.
Environment
mainat3ed2709(or any commit including #507's96ca8d7)Logs, screenshots, or video
See stack trace above.
docker service ps sillytavern_marinarashows endlessFailed → Ready → Failedcycles withtask: non-zero exit (1).Additional context
Suggested fix: defer the
sharedLogger.warncall past the import cycle (e.g. wrap it insetImmediate), so the binding is initialized by the time the warn runs. The diagnostic is preserved without crashing startup. PR to follow.Template check