[PR #758] [MERGED] Fix Termux startup when sharp cannot load #4763

Closed
opened 2026-10-22 04:10:26 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/758
Author: @Xelvanis
Created: 5/12/2026
Status: ✅ Merged
Merged: 5/12/2026
Merged by: @Xelvanis

Base: main ← Head: fix/termux-sharp-startup


📝 Commits (2)

  • 0f0765e Fix Termux startup when sharp cannot load
  • 7bba143 Address game asset sharp review feedback

📊 Changes

1 file changed (+42 additions, -8 deletions)

View changed files

📝 packages/server/src/routes/game-assets.routes.ts (+42 -8)

📄 Description

Linked issue

Related: #746
Related: #752

Why this change

Termux users can reach the startup banner and then the server exits while loading sharp with the Android ARM64 runtime. Game asset image metadata is nice-to-have enrichment, but it should not block the entire app from booting on platforms where sharp cannot load.

What changed

  • Lazy-load sharp inside the Game Assets route instead of importing it during server startup.
  • Skip optional width/height/format metadata when sharp is unavailable, while still returning basic file info.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

Automated/local proof performed:

  • Reproduced the startup import failure by importing packages/server/dist/routes/game-assets.routes.js with a Node ESM loader that makes sharp throw during module evaluation. Before the fix, this exited with IMPORT_FAILED.
  • Rebuilt the server and reran the same import simulation. After the fix, it exited with IMPORT_OK.
  • Checked GET /api/game-assets/file-info/backgrounds/fantasy/mock.png with sharp forced unavailable. The endpoint returned 200 with basic file info and omitted optional image metadata fields.
  • Ran pnpm check; it passed locally.

Still needs human/device verification:

  • Run ./start-termux.sh on an Android/Termux install that previously crashed with the sharp android-arm64 runtime error.

nah, gl guys

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

Not applicable; this is a server startup/runtime fallback fix.

Summary by CodeRabbit

  • Bug Fixes
    • Improved platform compatibility by implementing lazy loading of native dependencies, preventing startup issues on systems without native support.
    • Enhanced image metadata enrichment to conditionally extract and display image dimensions and format information with robust error handling for extraction failures.

Review Change Stack


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/758 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/12/2026 **Status:** ✅ Merged **Merged:** 5/12/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `main` ← **Head:** `fix/termux-sharp-startup` --- ### 📝 Commits (2) - [`0f0765e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0f0765e7363ee3b1b9d918566058351135fb6cdb) Fix Termux startup when sharp cannot load - [`7bba143`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7bba143bff83cb9ee10d7343d66cd0b9f6f7dead) Address game asset sharp review feedback ### 📊 Changes **1 file changed** (+42 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/game-assets.routes.ts` (+42 -8) </details> ### 📄 Description ## Linked issue Related: #746 Related: #752 ## Why this change Termux users can reach the startup banner and then the server exits while loading `sharp` with the Android ARM64 runtime. Game asset image metadata is nice-to-have enrichment, but it should not block the entire app from booting on platforms where `sharp` cannot load. ## What changed - Lazy-load `sharp` inside the Game Assets route instead of importing it during server startup. - Skip optional width/height/format metadata when `sharp` is unavailable, while still returning basic file info. ## Validation - [x] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes Automated/local proof performed: - Reproduced the startup import failure by importing `packages/server/dist/routes/game-assets.routes.js` with a Node ESM loader that makes `sharp` throw during module evaluation. Before the fix, this exited with `IMPORT_FAILED`. - Rebuilt the server and reran the same import simulation. After the fix, it exited with `IMPORT_OK`. - Checked `GET /api/game-assets/file-info/backgrounds/fantasy/mock.png` with `sharp` forced unavailable. The endpoint returned `200` with basic file info and omitted optional image metadata fields. - Ran `pnpm check`; it passed locally. Still needs human/device verification: - Run `./start-termux.sh` on an Android/Termux install that previously crashed with the `sharp` android-arm64 runtime error. nah, gl guys ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) Not applicable; this is a server startup/runtime fallback fix. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved platform compatibility by implementing lazy loading of native dependencies, preventing startup issues on systems without native support. * Enhanced image metadata enrichment to conditionally extract and display image dimensions and format information with robust error handling for extraction failures. [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/758) <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:10:26 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4763
No description provided.