Skip to content

fix: notarize --json crashes with a TypeError - #80

Closed
SafraNako wants to merge 1 commit into
theQRL:masterfrom
SafraNako:fix/notarize-json-crash
Closed

SafraNako wants to merge 1 commit into
theQRL:masterfrom
SafraNako:fix/notarize-json-crash

Conversation

@SafraNako

Copy link
Copy Markdown

Problem

notarize starts its spinner as:

const spinner = flags.json ? null : ora({ text: 'Notarising Data...\n' }).start()

but then calls spinner.succeed(...) / spinner.fail(...) unconditionally
throughout run() (line 97 spinner.succeed(...) is the first one on the
happy path). So any --json invocation dies immediately:

$ ./bin/run notarize <sha256> -h "<hexseed>" -i 0 -j
TypeError: Cannot read properties of null (reading 'succeed')

The -j / --json flag is documented ("Return JSON response") but has
never worked. spinner3 and spinner4 further down are always-on ora
instances too, so their progress lines would have corrupted the JSON even
with spinner guarded.

Fix

A small makeSpinner(text) helper — a real ora spinner normally, a
chainable no-op object under --json — used for all three spinners.
Non---json output is byte-for-byte unchanged.

$ ./bin/run notarize <sha256> -h "<hexseed>" -i 3 -j -t
[{"tx_id":"060e58a8ab25b9b836e2277ff98a7da59a34fdbe59a8150c47d3b9e15f815d8c"}]

Tests

notarize #8b: notarize ... -j against a deliberately unreachable grpc
endpoint must exit non-0 without a TypeError in its output. Fails on
master (TypeError: Cannot read properties of null (reading 'succeed')),
passes with this change. npm run lint clean; existing non---json
notarize tests are unaffected (the helper returns the same ora(...).start()).

🤖 Generated with Claude Code

`notarize` sets `const spinner = flags.json ? null : ora(...).start()` but
then calls `spinner.succeed(...)` / `spinner.fail(...)` unconditionally
(~20 sites), so `notarize <hash> -h <seed> -i <n> -j` throws
`TypeError: Cannot read properties of null (reading 'succeed')` at the
first call and never reaches the JSON output path. `spinner3` / `spinner4`
were also always-on `ora` instances, so their progress text would have
corrupted the JSON even if `spinner` were guarded.

Add a `makeSpinner(text)` helper: a real `ora` spinner normally, a
chainable no-op object under `--json`. All three spinners go through it.
Non-`--json` behaviour is unchanged.

Adds `notarize #8b`: `notarize ... -j` against an unreachable endpoint
must exit non-0 without a `TypeError` in its output (fails before this
change).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@jplomas

jplomas commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Thanks, this PR crosses with some fork work which closes this issue. Thank you for your contribution.

@jplomas jplomas closed this Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants