Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StreamSignal.dispose() (and FutureSignal) throws SignalsWriteAfterDisposeError #171

Closed
mernen opened this issue Feb 15, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@mernen
Copy link
Contributor

mernen commented Feb 15, 2024

Test:

var signal = streamSignal(() => Stream.value(1));
signal.dispose();

This happens because dispose() calls reset(), which in turn calls AsyncSignal.reset(), which then calls set value, which notices the signal has already been disposed.

The simplest fix is to move super.dispose() to be the last operation in dispose(), since conceptually deinitialization should be done in reverse order of initialization. But I'm a bit worried the library is doing too much during disposal. For example, the last step of reset() is to set _initialized to true, which doesn't make sense in a disposed object.

@rodydavis rodydavis added the bug Something isn't working label Feb 15, 2024
@rodydavis
Copy link
Owner

There was some recent changes to autoDisposing and need to update the async signal implementation to reflect the correct order.

That error was a new addition. Will update and add some tests.

On the old version of stream/future signal it was using dispose as a reset to default but not destroying it. Now signals that call dispose should not be written to after.

Thanks for capturing this!

@rodydavis rodydavis changed the title StreamSignal.dispose() (and FutureSignal) throws SignalsWriteAfterDisposeError [Bug] StreamSignal.dispose() (and FutureSignal) throws SignalsWriteAfterDisposeError Feb 15, 2024
@rodydavis rodydavis changed the title [Bug] StreamSignal.dispose() (and FutureSignal) throws SignalsWriteAfterDisposeError StreamSignal.dispose() (and FutureSignal) throws SignalsWriteAfterDisposeError Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants