remix-run/remix · error · TypeError

import.meta.hot.accept() can only accept a callback, a strin

Error message

import.meta.hot.accept() can only accept a callback, a string literal, or an array of string literals.

What it means

During HMR accept-analysis, import.meta.hot.accept() must be called with no arguments (self-accept), a single string literal dependency, or an array of string literals. Passing variables, expressions, non-string values, or unexpected extra arguments makes hot-update boundaries unresolvable statically, so analysis throws a TypeError with this message.

Source

Thrown at packages/node-hmr/src/lib/hmr-analysis.ts:66

  }

  walkAst(parseResult.program, (node) => {
    if (isImportMetaHotNode(node)) {
      usesImportMetaHot = true
    }

    if (node.type !== 'CallExpression') return
    if (!isImportMetaHotAcceptCallee(node.callee)) return

    let [firstArgument] = node.arguments
    if (firstArgument === undefined || isSelfAcceptArgument(firstArgument)) {
      selfAccepting = true
      return
    }

    let deps = getAcceptedDependencies(firstArgument)
    if (deps === null) {
      throw new TypeError(invalidAcceptMessage)
    }

    acceptedDeps.push(...deps)
  })

  return {
    acceptedDeps,
    selfAccepting,
    usesImportMetaHot,
  }
}

function isImportMetaHotAcceptCallee(node: Node): boolean {
  let callee = unwrapChainExpression(node)
  if (callee.type !== 'MemberExpression') return false
  if (callee.computed || !isIdentifierNode(callee.property, 'accept')) return false

  return isImportMetaHotNode(callee.object)

View on GitHub (pinned to 9696913134)

Solutions

  1. Use literal strings: import.meta.hot.accept('./dep.ts') or accept(['./a.ts', './b.ts'])
  2. For self-accepting modules call import.meta.hot.accept() with no arguments
  3. Keep dependency lists static — build literal arrays at the call site, not from variables

Example fix

// before
let dep = './counter.ts'
import.meta.hot.accept(dep)

// after
import.meta.hot.accept(['./counter.ts'])
// or, if the module accepts its own updates:
import.meta.hot.accept()
Defensive patterns

Strategy: validation

Validate before calling

// keep accept calls static; verify with a quick grep before running:
// every import.meta.hot.accept( call should have (), ('...') or (['...','...'])

Prevention

When it happens

Trigger: Calling import.meta.hot.accept(someVariable), accept(['a', condition ? 'b' : 'c']), accept(123), or accept with dynamic/computed dependency expressions in a module processed by node-hmr's HMR analysis.

Common situations: Refactoring HMR code to use computed dependency names; copy-pasting Vite patterns that use variables; generated code inserting non-literal arguments.

Related errors


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