LearnNewsExamplesConnect
Frontmatter
assigneesneo-gpt-euclid
createdAtOct 6, 2026, 5:09 PM
updatedAtOct 6, 2026, 10:44 PM
githubUrlhttps://github.com/neomjs/neo/issues/19430
authorneo-opus-grace
commentsCount2
parentIssuenull
subIssues
19436 Fetch string-form request metadata is circular
subIssuesCompleted1
subIssuesTotal1
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtOct 6, 2026, 10:44 PM

Stream and Fetch miss a workspace's relative data URLs in dev mode

neo-opus-grace
neo-opus-grace commented on Oct 6, 2026, 5:09 PM

Context

Found on 2026-10-06 while deploying DevIndex's environments (neomjs/devindex#60). @neo-opus-grace first diagnosed it on 2026-08-19 but never filed it. DevIndex is a workspace: neo.mjs is a dependency under node_modules/neo.mjs, as in every npx neo-app workspace.

The Problem

In a workspace's dev mode the page sits at apps/<app>/ and the workers run from node_modules/neo.mjs/src/worker/. A worker resolves a relative URL against its own script. So DevIndex's store URL, Neo.config.basePath + 'apps/devindex/resources/data/users.jsonl' with basePath: '../../' written for the page, lands at node_modules/neo.mjs/apps/devindex/resources/data/users.jsonl.

Measured in headless Chromium on 2026-10-06, against the devindex workspace on neo.mjs 13.1.0:

  • At an origin root, dev mode fetches /node_modules/neo.mjs/apps/devindex/resources/data/users.jsonl and gets a 200. That is only because neo.mjs@13.1.0 still ships DevIndex's own data, the copy #17240 later removed. The grid shows that stale copy instead of the workspace's index, and nothing turns red.
  • Under a mount (/devindex/), the same fetch is a 404 and the grid stays empty.
  • From 13.2.0, which no longer ships apps/devindex, it is a 404 at an origin root too.

The engine already compensates for this offset in two places, each its own way:

  • src/data/connection/Xhr.mjs:186 prefixes ../../ to a relative URL when the worker runs inside node_modules/neo.mjs. It applies to Xhr only, and it keys on the hostname (!location.href.startsWith('https://neomjs.com/')).
  • src/worker/App.mjs:746 does the same for the theme map, keyed on Neo.config.workerBasePath containing node_modules.

src/data/connection/Fetch.mjs:115 and src/data/connection/Stream.mjs:71 pass the URL to fetch() unchanged.

The Architectural Reality

  • Neo.data.connection.Base is the shared base of Fetch, Stream and Xhr.
  • basePath stays page-relative. The Stylesheet addon depends on its relative form (basePath.substring(6)), and an absolute basePath broke DevIndex's boot when measured on 2026-08-19.
  • A fixed ../../ fits only a page two levels below the workspace root. A nested child app (four levels, as in neomjs/multiwindowcolors) already reaches the root from the worker without a prefix, so a fixed prefix overshoots there.
  • The page URL already travels. Neo.worker.Manager sends config.url = {href, search} at registration, on both the initial and the lazy path (src/worker/Manager.mjs:314, :832). href is not the base a relative URL resolves against, though: a page with <base> resolves against its effective document base, document.baseURI. Since neomjs/devindex#62, DevIndex's built entries carry <base href="../../">, so href would resolve them into dist/<env>/apps/devindex/… instead of the shared site root (@neo-gpt's intake, 6019828439).
  • A shared realm keeps the first window's config. Neo.worker.Base#onRegisterNeoConfig merges a registration into Neo.config only while Neo.config.windowId is unset (src/worker/Base.mjs:655). A second window's registration changes nothing global; the App worker keeps each window's own config in Neo.windowConfigs[windowId] (src/worker/App.mjs:737). Stores and connections carry no window.

The Fix

  1. Delivery. Main adds the effective document base to the existing payload: config.url = {base: document.baseURI, href, search}, on both registration paths.
  2. Gate. The rule applies only in a workspace's dev-mode layout: the worker runs inside node_modules/neo.mjs/ (its own location) while the realm's document base does not. Everywhere else, connections keep today's worker-relative resolution. That covers the engine repo, every dist build including neomjs/devindex#62's entries (their workers sit in dist/<env>/), and a page served from inside the package, the case Xhr's hostname branch skipped.
  3. Resolution. One method on Neo.data.connection.Base, used by Fetch, Stream and Xhr, resolves a relative URL (./, ../) with new URL(url, Neo.config.url.base). It replaces Xhr's hostname branch, and Xhr's insideNeo opt-out keeps its meaning.
  4. Selection, stated, not implied. A realm resolves against Neo.config.url.base, the base of the window that registered it, which is the window Neo.config already describes. In a shared realm whose windows have different document bases, a connection serving another window passes an absolute URL. That is the per-connection override; no first- or last-window pick happens implicitly.

Contract Ledger

Target Surface Source of Authority Proposed Behavior Fallback / Edge Case Docs Evidence
config.url.base: a new field in the registration payload Neo.worker.Manager sends (Manager.mjs:314, :832) this ticket; @neo-gpt's intake document.baseURI of the registering window, beside the existing href and search Additive: existing readers of url.href and url.search are unchanged. A worker started without registration has no base and keeps worker-relative resolution JSDoc where the payload is built Unit: both registration paths carry base, and a page with <base> sends its effective base, not href
Neo.data.connection.Base relative-URL resolution, used by Fetch, Stream, Xhr this ticket; the existing offsets at Xhr.mjs:186 and App.mjs:746 In a workspace's dev-mode layout (the gate above), a relative URL resolves against Neo.config.url.base; elsewhere, unchanged Absolute URLs pass through. Without url.base, resolution stays worker-relative. Xhr's insideNeo opt-out keeps its meaning. A second window's base never replaces the realm's; a connection serving another window passes an absolute URL JSDoc on the resolving method The criteria below

Acceptance Criteria

  • In a workspace's dev-mode layout, Fetch, Stream and Xhr resolve a relative URL to the URL the page would, for a page two and four levels below the workspace root, at an origin root and under a mount. Specs pin each case.
  • Built-entry control: a page with <base> and its workers outside node_modules (neomjs/devindex#62's layout) resolves exactly as before.
  • Two-window control: windows A then B register with different bases; the realm resolves against A's, Neo.windowConfigs keeps B's, and an absolute URL passes through.
  • insideNeo control: an Xhr request with insideNeo resolves as before.
  • Xhr's hostname branch is gone, and the engine repo's own apps fetch exactly as before; existing specs stay green.

Post-Merge Validation

  • [L3-deferred — operator handoff needed] After a release, DevIndex's dev mode paints its grid from the workspace's own index. An unmerged Engine PR cannot deliver this; the outcome is already accepted by its owner. Residual-Owner: neomjs/devindex#61.

Out of Scope

  • basePath itself, and the Stylesheet addon's relative paths.
  • Direct fetch() calls in app code outside the connections.

Related

#17240 (DevIndex's data left the package), #17976 (dist/esm resolved basePath to the repo root), neomjs/devindex#60 (the Pages environments that found this).

Live latest-open sweep: checked the latest 20 open neomjs/neo issues at 2026-10-06T15:05:55Z; no equivalent. A2A claim sweep: the latest 25 lane claims; no overlapping claim. MC sweep: "workspace dev mode worker resolves Neo.config.basePath…", 6 results. They surfaced the 2026-08-19 diagnosis (no ticket filed), the Xhr compensation (noted 2026-02-24) and the path-base analysis of 2026-08-27; none is a decision against fixing it. Own-assignment sweep: 2 open (#14800, #15000); none overlapping.

Origin Session ID: 40a3c119-6419-4e87-9248-002c686708fe

Retrieval Hint: "workspace dev mode worker relative URL node_modules/neo.mjs Stream Fetch Xhr basePath"

tobiu referenced in commit 966eec8 - "feat(data): resolve workspace connection URLs from document base (#19430) (#19435) on Oct 6, 2026, 10:44 PM
tobiu closed this issue on Oct 6, 2026, 10:44 PM