Skip to content

fix(haunted-polymer): add resume/pause lifecycle calls for pion 2.13.0 compatibility#235

Merged
cristinecula merged 1 commit into
masterfrom
fix/haunted-polymer-scheduler-lifecycle
Mar 31, 2026
Merged

fix(haunted-polymer): add resume/pause lifecycle calls for pion 2.13.0 compatibility#235
cristinecula merged 1 commit into
masterfrom
fix/haunted-polymer-scheduler-lifecycle

Conversation

@megheaiulian
Copy link
Copy Markdown
Contributor

Summary

  • Add this._scheduler.resume() before this._scheduler.update() in connectedCallback
  • Add this._scheduler.pause() before this._scheduler.teardown() in disconnectedCallback

Problem

Pion 2.13.0 changed BaseScheduler._active from defaulting to true to defaulting to false. This is the correct behavior — the scheduler should only be active while the element is connected to the DOM.

However, hauntedPolymer in haunted-polymer.ts creates its own Scheduler extending BaseScheduler and never called resume() or pause(). It only called update() in connectedCallback and teardown() in disconnectedCallback.

With pion 2.13.0, update() silently exits when _active is false, so the haunted hook never runs. This breaks all hauntedPolymer consumers — hooks like useOnline, useIndicateEnviroment, useKeybindings etc. never execute.

Solution

This fix adds the proper lifecycle calls that match exactly what pion's own component implementation does in component.js:

connectedCallback() {
    super.connectedCallback();
    this._scheduler.resume();
    this._scheduler.update();
}
disconnectedCallback() {
    super.disconnectedCallback();
    this._scheduler.pause();
    this._scheduler.teardown();
}

Testing

  • Lint passes
  • Unit tests cannot run in this environment due to missing Playwright browsers, but the change follows the established pattern from pion's component implementation

…0 compatibility

Pion 2.13.0 changed BaseScheduler._active from defaulting to true to
defaulting to false. This is correct behavior - the scheduler should only
be active while the element is connected to the DOM.

However, hauntedPolymer's custom Scheduler extends BaseScheduler but never
called resume() or pause(). It only called update() in connectedCallback
and teardown() in disconnectedCallback. With pion 2.13.0, update() silently
exits when _active is false, so haunted hooks never execute.

This fix adds:
- this._scheduler.resume() before this._scheduler.update() in connectedCallback
- this._scheduler.pause() before this._scheduler.teardown() in disconnectedCallback

This matches the lifecycle pattern used by pion's own component implementation.
@cristinecula cristinecula merged commit 941a7b2 into master Mar 31, 2026
7 checks passed
@cristinecula cristinecula deleted the fix/haunted-polymer-scheduler-lifecycle branch March 31, 2026 16:15
github-actions Bot pushed a commit that referenced this pull request Mar 31, 2026
## [6.20.1](v6.20.0...v6.20.1) (2026-03-31)

### Bug Fixes

* **haunted-polymer:** add resume/pause lifecycle calls for pion 2.13.0 compatibility ([#235](#235)) ([941a7b2](941a7b2))
@github-actions
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 6.20.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants