Skip to content

Fresh Streams browser resolver cannot see Aspire VITE service references #1548

Description

@rickylabs

Reproduction

With @netscript/fresh@0.0.5, create a Fresh/Vite island using the documented factory without a baseUrl override:

createNetScriptStreamDB({
  streamPath: '/workers/executions',
  schema,
})

Run it from an Aspire AppHost that injects both canonical browser references into the dashboard process:

  • VITE_services__streams__http__0=http://localhost:4437
  • VITE_STREAMS_URL=http://localhost:4437

The island throws before connecting:

Durable streams URL not found. Expected DURABLE_STREAMS_URL or
services__streams__http__0 (server) / VITE_services__streams__http__0
(browser) in the environment.

Cause

getBrowserServiceEndpoint() calls readImportMetaEnvironment(import.meta). Vite substitutes import.meta.env expressions, but does not attach an env property to a bare import.meta passed through a helper, particularly in the JSR dependency module served by Fresh/Vite. Consequently, both injected variables are present in the process but invisible to the resolver in the browser bundle.

Expected

The documented zero-configuration browser factory should resolve Aspire's canonical Vite service reference and connect directly to Streams.

Temporary consumer path

Passing the factory's documented baseUrl override from a statically substituted application expression works:

baseUrl: import.meta.env.VITE_services__streams__http__0 ??
  import.meta.env.VITE_STREAMS_URL

This keeps NetScript in control of the /v1/stream/netscript URL and transport, but duplicates discovery at each consumer. A package-side direct import.meta.env.VITE_* lookup (or a Vite-plugin transform) would remove that drift.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions