fix: guard null PIXI stage and detach spiderhog listener on teardown - #35
Draft
posthog[bot] wants to merge 1 commit into
Draft
fix: guard null PIXI stage and detach spiderhog listener on teardown#35posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
The spiderhog skin registers a global pointerdown listener that spawns a web on every click. HedgeHogMode.destroy() tore down the PIXI app without unloading its elements, so that listener survived teardown and a later click spawned onto a destroyed app — dereferencing a null app.stage in Actor.loadSpriteFrames. The same null stage exists briefly before app.init() resolves. - destroy() now runs beforeUnload() on every element before destroying the app, so ability-owned listeners (the spiderhog pointerdown) detach. - loadSpriteFrames, SpiderWebActor.spawn, and the removeChild sites bail when the stage is absent, so a stray spawn during the init/teardown gap no-ops instead of crashing. Bumps the package to 0.0.54. Generated-By: PostHog Code Task-Id: f2e7dabb-cb62-4d61-b4b0-32c1809252cb
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
richardsolomou
requested changes
Jul 29, 2026
| // Unload every element while the stage is still alive so listener-owning | ||
| // abilities detach — notably the spiderhog skin's global pointerdown, which | ||
| // would otherwise survive teardown and spawn a web onto a destroyed app. | ||
| for (const element of [...this.elements]) { |
Member
There was a problem hiding this comment.
this should cancel element-owned timers and tweens during teardown, or make beforeUnload() idempotent. released webs and flames retain callbacks that later call removeElement(). after this sweep has already cleaned them up, those callbacks repeat cleanup, decrement the global spawn counters twice, and may destroy PIXI resources twice.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes a rare uncaught
TypeError: Cannot read properties of null (reading 'addChild')in the toolbar-embedded hedgehog mode.The spiderhog skin registers a global
pointerdownlistener that spawns aSpiderWebActoron every click.HedgeHogMode.destroy()tore down the PIXI app (app.destroy()) without unloading its elements, so that listener stayed attached after teardown. A later click then spawned onto a destroyed app and dereferenced a nullapp.stageinActor.loadSpriteFrames. The same null-stage window exists briefly beforeapp.init()resolves.Changes
destroy()now callsbeforeUnload()on every element before destroying the app, so ability-owned listeners — notably the spiderhogpointerdown— detach and can't fire post-teardown.Actor.loadSpriteFrames,SpiderWebActor.spawn, and theremoveChildsites bail when the stage is absent, so any stray spawn during the init/teardown gap no-ops instead of crashing.0.0.54(auto-published on merge tomain).Why
Genuine uncaught crash in production-served toolbar code. Impact is small — it's an opt-in cosmetic easter egg and needs a narrow
pointerdowntiming race — but the fix is cheap and self-contained.Testing
pnpm lintandpnpm buildpass.test/spider-web-actor.test.tscovering thespawnnull-stage guard.Created with PostHog Code from an inbox report.