Skip to content

fix: only invoke onRuntimeError with null after a previously reported error#96

Closed
git-chad wants to merge 1 commit into
chore/lint-cleanupfrom
fix/81-onruntimeerror-null
Closed

fix: only invoke onRuntimeError with null after a previously reported error#96
git-chad wants to merge 1 commit into
chore/lint-cleanupfrom
fix/81-onruntimeerror-null

Conversation

@git-chad

@git-chad git-chad commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Closes #81.

Problem

<ShaderLabComposition> called onRuntimeError(null) after every successful renderer init and config change (the null was an internal "clear error state" signal leaking through the consumer callback). The README example doesn't null-check, so anyone copying it logged null errors — or pinned a permanent false error in their UI.

Fix

handleRuntimeError still updates the internal overlay state unconditionally, but only invokes the consumer callback when the message differs from the last delivered one (tracked in a component-level ref that survives config-change effect re-runs). The browserSupportsWebGPU() failure branch now routes through the same funnel.

Consumer-visible behavior:

Scenario Before After
First successful init called with null not called
Config change, still successful called with null again not called
Real error called called once
Same error repeats called each time deduplicated
Error then recovery called with null exactly once
Recovery then new error called called with new message

Also documents the semantics on the prop's JSDoc and updates both READMEs' example to null-check (with a paragraph explaining the null-on-recovery contract).

Patch changeset included.

Verification

Package typecheck, bun run build:runtime, bun run typecheck:tsc, bun run lint, bun test, and bunx changeset status --since=origin/main all pass.

Stacked on #92 (lint cleanup). Merge #92 first; GitHub retargets this to main.

🤖 Generated with Claude Code

… error

ShaderLabComposition called the consumer onRuntimeError callback with
null after every successful renderer initialization (and after every
successful shader recompile via the internal error channel), because
null was used as a success/cleared signal on the same path as real
errors. Consumers following the README example logged "null" on every
clean init, and apps mirroring the message into UI state showed a
permanent false error.

The composition now tracks the last message actually delivered to the
consumer in a ref that survives config-change re-inits:

- null on a clean init is a no-op toward the consumer (internal error
  overlay state is still cleared)
- after a real error was delivered, resolving it calls the consumer
  with null exactly once so error UIs can recover
- consecutive identical errors and repeated clears are deduplicated

Also documents the callback semantics in the onRuntimeError JSDoc and
the README error-handling example, and adds a patch changeset.

Fixes #81

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
shader-lab Ready Ready Preview, Comment Jul 6, 2026 11:23pm

@git-chad

git-chad commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Consolidated into #104.

@git-chad git-chad closed this Jul 7, 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.

1 participant