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

Remove cancellation hook from Future.finally #281

Merged
merged 1 commit into from
Aug 30, 2018
Merged

Conversation

Avaq
Copy link
Member

@Avaq Avaq commented Aug 30, 2018

A less severe alternative to #279


To make Future.finally more reliable as a tool which guarantees
execution of the cleanup handler, it would run and cancel the handler
when it would itself be cancelled.

However, this behaviour is subject to some issues:

  • The cleanup handler would run when a Future prior to the finally-call
    got cancelled, leading to attempts to dispose yet-to-be-acquired
    resources.
  • The cleanup handler would be immediately cancelled, which meant that
    unless it was prepared for ignoring the cancellation signal, cleanup
    wouldn't even happen.

This commit fixes both of those issues by removing this behaviour
altogether. Finally then becomes a function to use solely for cases
where something should happen as a side-effect under rejection and under
resolution of a Future, as its documentation already states.

@codecov
Copy link

codecov bot commented Aug 30, 2018

Codecov Report

Merging #281 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #281   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          48     48           
  Lines         990    989    -1     
  Branches      215    215           
=====================================
- Hits          990    989    -1
Impacted Files Coverage Δ
src/future.mjs 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 04c3025...84119ee. Read the comment docs.

To make Future.finally more reliable as a tool which guarantees
execution of the cleanup handler, it would run and cancel the handler
when it would itself be cancelled.

However, this behaviour is subject to some issues:

- The cleanup handler would run when a Future prior to the finally-call
  got cancelled, leading to attempts to dispose yet-to-be-acquired
  resources.
- The cleanup handler would be immediately cancelled, which meant that
  unless it was prepared for ignoring the cancellation signal, cleanup
  wouldn't even happen.

This commit fixes both of those issues by removing this behaviour
altogether. Finally then becomes a function to use solely for cases
where something should happen as a side-effect under rejection and under
resolution of a Future, as its documentation already states.
@Avaq Avaq merged commit 4fd47e6 into master Aug 30, 2018
@Avaq Avaq deleted the avaq/fix-finally branch August 30, 2018 16:48
Avaq added a commit that referenced this pull request Aug 30, 2018
Breaking changes

- #276 The "module" package file has been renamed from index.mjs.js to index.mjs.
- #277 It is no longer possible to use Future.ap, Future.map, Future.bimap,
  Future.chain, or Future.alt on non-Fantasy Land types.
  If you were using any of these functions from Fluture to treat JavaScript's
  native types as Fantasy Land algebraic types, you should migrate those
  call-sites to use the Ramda or Sanctuary exported dispatchers instead.
- #281 Future.finally no longer runs the cleanup Future when it is cancelled.
  If you rely on this behaviour, I urge you to rewrite the relevant code with
  Future.hook (even if you don't upgrade Fluture).

New features

- #276 The Fluture source is now loadable by Node's experimental module loader,
  and the esm loader (https://github.com/standard-things/esm).
- #280 The Future.of function now has an alias 'resolve', which is exported
  statically as well as exposed as a property on the Future constructor.

Bug fixes and improvements

- #277 Fluture no longer depends on sanctuary-type-classes, reducing bundle size.
- #277 Performance of Fantasy Land dispatchers greatly improved.
- #281 The undesired consequences of the cancellation-related behaviour in
  Fluture.finally are gone now that the behaviour has been removed.
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