remix-run/remix · error · Error

Cannot install context property {formattedProperty} because

Error message

Cannot install context property {formattedProperty} because it already exists on RequestContext.

What it means

A context property name cannot shadow real members of the RequestContext class (like request, router, or set). This error fires when the property name collides with an existing own/inherited property on the context object.

Source

Thrown at packages/fetch-router/src/lib/request-context.ts:324

    if (existingProperty != null && existingProperty !== property) {
      throw new Error(
        `Cannot install context property ${formattedProperty} because this context key already uses ${JSON.stringify(existingProperty)}.`,
      )
    }

    let existingKey = this.#contextProperties.get(property)
    if (existingKey != null) {
      if (existingKey !== key) {
        throw new Error(
          `Cannot install context property ${formattedProperty} because another context key already uses it.`,
        )
      }

      return
    }

    if (property in this) {
      throw new Error(
        `Cannot install context property ${formattedProperty} because it already exists on RequestContext.`,
      )
    }

    this.#contextProperties.set(property, key)
    this.#contextPropertyKeys.set(key, property)

    Object.defineProperty(this, property, {
      get: () => this.get(key),
    })
  }

  #router?: Router<any>

  /**
   * The router handling this request.
   */
  get router(): Router<RequestContext<any, entries>> {

View on GitHub (pinned to 9696913134)

Solutions

  1. Pick a distinct property name (e.g. 'routeParams' instead of 'params' if built-in)
  2. Read built-in members directly instead of installing them as context properties
  3. Namespace custom properties: 'appParams', 'authSession'

Example fix

// before
ctx.set(key, v, { property: 'request' })
// after
ctx.set(key, v, { property: 'rawRequest' })
Defensive patterns

Strategy: validation

Validate before calling

if (property in ctx) throw new Error('property shadows RequestContext member')

Type guard

const isBuiltIn = (ctx: object, p: string) => p in ctx

Prevention

When it happens

Trigger: ctx.set(key, v, { property: 'router' }) or 'request', 'url', 'set' — any name already present on RequestContext instances.

Common situations: Middleware wanting a convenient ctx.params or ctx.url accessor that clashes with built-in context members.

Related errors


AI-assisted analysis of remix-run/remix@9696913134 (2026-08-27). Data as JSON: /api/errors/a94b91084df0a8f9. Report an issue: GitHub.