Skip to content

fix: SessionEnd hook crash when script outputs no JSON #9

Closed

Description

@dahai80

Bug

When exiting fusion-code, if a SessionEnd hook script (e.g. remote-skill-update-check.js) exits with code 0 but produces no JSON on stdout, the hook framework crashes with:

SessionEnd hook [node "...remote-skill-update-check.js"] failed: undefined is not an object (evaluating 'R.hookSpecificOutput')

Root Cause

src/utils/hooks.ts line 3388 in executeHooksOutsideREPL:

const hso2 = (json as TypedHookJSON).hookSpecificOutput;

parseHookOutput returns json = null when the hook script outputs no JSON. Accessing .hookSpecificOutput on null throws.

Fix

Add null guard:

const hso2 = json
    ? (json as TypedHookJSON).hookSpecificOutput
    : undefined;

Reproduction

  1. Configure a SessionEnd hook that exits 0 with no stdout
  2. Exit fusion-code
  3. Observe crash message on stderr

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions