Skip to content

fix(core): dispose internal/update hooks with the fiber - #56

Open
tdwhere123 wants to merge 2 commits into
cordiverse:mainfrom
tdwhere123:fix/core-internal-update-hooks
Open

fix(core): dispose internal/update hooks with the fiber#56
tdwhere123 wants to merge 2 commits into
cordiverse:mainfrom
tdwhere123:fix/core-internal-update-hooks

Conversation

@tdwhere123

Copy link
Copy Markdown

Problem

Non-global ctx.on('internal/update') is intercepted in EventsService and stored on fiber._hooks, then on() returns early so the listener never becomes a fiber effect. _unload only clears _disposables. The Fiber instance is reused across reloads, so each fiber.update() keeps the previous generation's closures.

Three config updates on current main therefore dispatch 1 + 2 + 3 listeners:

Observation Current main This change
update({ n: 1/2/3 }) [1, 2, 2, 3, 3, 3] [1, 2, 3]
explicit dispose() before update that generation does not run unchanged
{ global: true } listener not tied to child reload unchanged

The accumulation regressions fail on 8cc9e33 with those extra calls and pass on this branch.

Change

Register the special-cased listener through fiber.effect, so _unload already drops it. Do not clear fiber._hooks and do not touch _unload (that path is being rewritten in #39).

This PR is independent of #55 (internal/status isolation) and does not change register() / _resolve (#51).

Regression coverage

packages/core/tests/update-hooks.spec.ts covers accumulation across reloads, explicit dispose of the current generation, and that global internal/update hooks are not bound to a child fiber's reload.

Validation

  • yarn lint
  • yarn yakumo tsc
  • yarn test cordis/update-hooks — 3 tests passed
  • yarn test cordis — 13 files, 74 tests passed
  • yarn test:json — 20 files, 166 tests passed
  • git diff --check origin/main...HEAD — passed

Non-global internal/update listeners skipped fiber.effect registration, so reloads left stale closures in fiber._hooks. Register them as effects so unload drops the previous generation.
…fect

fiber.effect already treats the callback return as the disposer; DisposableList.push is that remover, so the extra binding is noise.
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