Skip to content

Proposal: replace Next.js with Bun (Bun.serve + Bun bundler) #346

Closed

Description

@andrebrait

Summary

omp-web uses very little of Next.js: three pages, all of which render the client-side AppShell, plus 70 API route handlers written against the Web Request/Response API. Meanwhile, Next blocks features we need. I propose running omp-web on Bun: Bun.serve for the API, static files and WebSockets, and Bun's bundler for the React app. The implementation is #344, stacked on #342. User-visible behavior, URLs, ports and environment variables stay the same.

Why

  • No WebSocket support. Remote and local hosts (feat(hosts): run sessions on other machines through an ompweb host daemon #339, feat(hosts): omp runs survive web-server restarts through a local daemon #342) link to the web server over several long-lived HTTP legs, with separate requests for binary data. A WebSocket would replace them with one socket that carries text and binary frames. A Next route handler cannot accept the WebSocket handshake (the HTTP upgrade); the only way around it is a custom server wrapped around Next.
  • Body limit. The proxy layer silently truncates request bodies over 10 MB, so /api/hosts/link has to bypass it.
  • Two module instances. The startup hook (instrumentation) and the route handlers load separate copies of the same modules, which has already caused a class-identity bug.
  • Traps. For example, next build during development breaks next dev, Google Fonts are downloaded at build time (a source of CI flakes), and AGENTS.md has to warn that "this is NOT the Next.js you know".
  • It matches omp. omp is a Bun program, and Bun includes most of what we use separately today: TypeScript without a loader, SQLite, image resizing (Bun.Image replaces sharp), proxy support in fetch (replaces undici), and a test runner.

Feasibility spike (Linux)

Area Result
API routes All 70 load and run under Bun.serve; Bun's 10 s idle timeout is lifted per authenticated request so SSE and the host link stay open
WebSocket Auth checked before the upgrade; text and binary frames in both directions
node:sqlite, web-push, startup hook, password gate Work unchanged (the PR then moves the store to bun:sqlite)
Front end Renders with small replacements for next/dynamic and next/navigation; fonts self-hosted
Tests The whole suite now runs under bun test (1985 pass in #344)
Thumbnails Bun.Image resize plus WebP output matches sharp

Distribution

The npm package bun becomes a dependency, so npm i -g @kahme247/ompweb and npx keep working with no separate Bun install. A small Node launcher runs the server under that Bun binary.

Open points

This was agreed with the maintainer beforehand; this issue records the rationale and tracks #344.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions