marktext/marktext · warning · Error

Unhandled signal type:${s.type}

Error message

Unhandled signal type:${s.type}

What it means

Thrown inside the sequence-diagram layout pass (Diagram.Layout.drawSVG_.forEach over signals) when a signal object's `type` is neither 'Signal' nor 'Note'. The layout switch handles those two types explicitly; any other type cannot be measured/positioned and is rejected.

Source

Thrown at packages/muyajs/lib/assets/libs/sequence-diagram-snap.js:1346

            b = a + 1
          } else if (s.placement == PLACEMENT.OVER && s.hasManyActors()) {
            // Over multiple actors
            a = Math.min(s.actor[0].index, s.actor[1].index)
            b = Math.max(s.actor[0].index, s.actor[1].index)

            // We don't need our padding, and we want to overlap
            extraWidth = -(NOTE_PADDING * 2 + NOTE_OVERLAP * 2)
          } else if (s.placement == PLACEMENT.OVER) {
            // Over single actor
            a = s.actor.index
            actorEnsureDistance(a - 1, a, s.width / 2)
            actorEnsureDistance(a, a + 1, s.width / 2)
            this.signalsHeight_ += s.height

            return // Bail out early
          }
        } else {
          throw new Error('Unhandled signal type:' + s.type)
        }

        actorEnsureDistance(a, b, s.width + extraWidth)
        this.signalsHeight_ += s.height
      },
      this
    )

    // Re-jig the positions
    var actorsX = 0
    _.each(
      actors,
      function (a) {
        a.x = Math.max(actorsX, a.x)

        // TODO This only works if we loop in sequence, 0, 1, 2, etc
        _.each(a.distances, function (distance, b) {
          // lodash (and possibly others) do not like sparse arrays

View on GitHub (pinned to e52106fd1c)

Solutions

  1. Treat the input as invalid diagram syntax and show a user-facing parse error rather than letting it reach layout.
  2. If extending the library, add the new signal type to the layout switch (and to drawSignal/drawNote).
  3. Filter the signal list before layout: drop or warn on entries whose type is not 'Signal' or 'Note'.
  4. Upgrade muyajs / the bundled sequence-diagram-snap.js if a parser fix exists upstream.

Example fix

// before
} else {
  throw new Error('Unhandled signal type:' + s.type)
}
// after — skip unknown with a warning
} else {
  console.warn('Unhandled signal type:', s.type, '— skipped during layout')
}
Defensive patterns

Strategy: validation

Validate before calling

const SIGNAL_TYPES = new Set(['Signal', 'Note'])
function isKnownSignalType(t: string): boolean { return SIGNAL_TYPES.has(t) }

Type guard

function isKnownSignal(s: { type: string }): boolean { return s.type === 'Signal' || s.type === 'Note' }

Try / catch

try { layout.drawSVG(signals) }
catch (e) { if (/Unhandled signal type/.test(e.message)) warnAndSkip(e) else throw e }

Prevention

When it happens

Trigger: A custom or malformed signal object pushed into the diagram's signal list with an unknown type; a parser bug creating a signal with a misspelled or unset type; a future signal kind not yet handled by the layout pass.

Common situations: User input that the parser turns into a partially-constructed signal (e.g. an incomplete self-message). A monkey-patched or forked sequence-diagram library introducing new signal types without updating the layout. Corrupt in-memory diagram state after an edit.

Related errors


AI-assisted analysis of marktext/marktext@e52106fd1c (2026-08-12). Data as JSON: /api/errors/f1d54bce71a1a8a1. Report an issue: GitHub.