proposal-signals / signal-polyfill

Implementation tracking the current state of https://github.com/tc39/proposal-signals
Apache License 2.0
185 stars 13 forks source link

Batch unsubscribe issue #2

Closed lifeart closed 1 month ago

lifeart commented 4 months ago

Once I'm trying to unsubscribe all computeds in the end of render cycle, I got this errors:

image

Cannot read properties of undefined (reading 'liveConsumerNode')
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'wrapper')

PR to play with: https://github.com/lifeart/glimmer-next/pull/118

How to reproduce:

Open https://deploy-preview-118--g-next.netlify.app/todomvc Add any todo item Try to switch between Active/Completed tabs

If I unsubscribe one-by-one, no issue appears:

export const w = new Signal.subtle.Watcher(() => {
    scheduleRevalidate();
});

// works fine
signalsToUnwatch.forEach((signal) => {
  w.unwatch(signal);
});

// breaking
w.unwatch(....signalsToUnwatch);