Skip to content

Reranker crashes on self-hosted: undefined is not an object (evaluating 'b.AI.run') #1321

Description

@koladefaj

Severity: medium (feature unusable self-hosted; falls back silently)

Environment

Supermemory Server 0.0.5 (self-hosted, official installer)
Runtime Bun v1.3.4 (5eb2145b), Linux x64
Deployment Docker (debian:bookworm-slim), single container, docker compose
Host Windows 11 + Docker Desktop, 8 GB RAM available to the engine
Embeddings local, Xenova/bge-base-en-v1.5, 768d, native backend
Endpoints used /v4/search

Summary

Passing rerank: true to /v4/search throws on the self-hosted server because
the reranker calls a Cloudflare Workers AI binding (env.AI.run) that only
exists in the Workers runtime. Outside Workers the binding is undefined, so
every rerank attempt throws and the search silently returns unranked results.

Steps to reproduce

  1. Self-host 0.0.5.
  2. POST /v4/search with { "q": "...", "searchMode": "memories", "rerank": true }.
  3. Observe the error in the server log on every call.

Expected

Either rerank works self-hosted, or the server no-ops it with a clear signal
(the binary already contains a sibling code path that checks the binding and
returns skipped: "missing_ai_binding" — the reranker path lacks that guard).

Actual

Reranking failed: TypeError: undefined is not an object (evaluating 'b.AI.run')

The hardcoded model is @cf/baai/bge-reranker-base, a Workers-AI-only model.

Impact

Rerank is entirely unavailable self-hosted, and the failure is only visible in
logs — callers think they got reranked results. Noisy logs, silent quality loss.

Workaround

Do not pass rerank: true when self-hosted.

Suggested fix

Guard the reranker path with the same missing_ai_binding check the sibling path
already uses, or provide a local reranker for self-hosted deployments.


Found while building a hackathon project on Supermemory Local. Happy to provide
the full crash log, container config, or a minimal repro on request.

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